Tag: jquery validate

validation动态添加的文本框

在下面的代码中,如何仅为动态添加的文本框validation空值,即r_score1,r_score2 ……… function validate() { //How to validate the r_Score.. textfields } $(document).ready(function() { for(var i=0;i< sen.length;i++) { row += '’; } $(‘#details’).append(row); });

jqueryvalidation缺失}属性列表后

我在这里有这个代码: $(“#order”).validate({ rules: { name: { required: true } lastname: { required: true } address: { required: true } telephone: { required: true digits: true } email: { required: true email: true } } submitHandler: function (form) { debug = true; $(form).ajaxSubmit(); $(“#thanks”).show(1000); $(“#datadiv”).hide(500); } }); 并且它在此代码中的第4行的firebug上的属性列表“错误后抛出”missing}。 而对于我的爱,我无法弄清楚为什么 – 因为我正在通过jquery文档做一切。

JQuery表单validation和提交脚本冲突

构建了一个简单的JQuery / Ajax简报注册表单,然后在事后添加了JQueryvalidation。 我对javascript / jquery不是很有经验; 几天来一直在努力,我的想法很平淡。 每个脚本单独工作。 如果删除了提交代码,validation器可以正常工作(虽然它可以在指定表单操作URL的情况下正常工作)。 提交脚本与删除的validation程序代码完美配合。 但是,如果两者都没有,则不会进行validation,表单仍然可以通过提交脚本提交。 我所有尝试整合两者的努力都失败了。 显然我错过了一些相当重要的东西。 即使是正确方向上的丝毫推动也会受到极大的赞赏 这是完整的代码: $(document).ready(function(){ // run validator, specifies name of css div that will be displayed // on error and hide when corrected $(“#nl”).validate({ errorContainer: “#errorcontainer”, }); }); $(function() { // These first three lines of code compensate for Javascript being turned on […]

在运行validation后,扩展Jqueryvalidation以显示/隐藏div或清除div

为了澄清,如何在jquery的validation插件运行其validationfunction之前运行自定义函数(这是查看所有字段并显示错误消息)? 现在我将所有错误输出到div。 我喜欢抓住validation事件并在运行旧错误之前清除div。 然后id喜欢显示/隐藏该div,如果它有任何由jqueryvalidation插件自动生成的标签。 我可以做任何事情,但弄清楚如何扩展事件,运行我需要的东西,然后调用validationfunction。 谢谢!

select2 validation – 选择至少一个值

我正在使用select2和jQuery Validation插件。 select2的HTML: Set Location select2启动: $(‘#select2Region’).select2({ minimumInputLength: 1, data: $.parseJSON(selectRegion), placeholder: “Enter your City here”, allowClear: true }); 数据填充得非常好。 现在,我希望用户选择一个值。 正如在Github中提到的 ,我试过这个: 尝试在规则的正上方添加ignore:”。 一个空字符串为我做了工作,因为忽略:null,无效。 这也是: $(‘.select2’).select2().change(function(){ $(this).valid(); }); 但他们都不适合我。 这样做的正确方法是什么?

使用内置的ASP.NET MVCvalidation和向导方法

我正在使用我的向导的JQuery Steps Plugin基本表单示例 。 在此示例中,您将注意到他们正在使用JQuery Validate插件,这是ASP.NET MVC在提交表单时自动使用的插件。 我试图弄清楚当用户点击继续时如何validation当前步骤中的表单字段,但使用ASP.NET MVC语法,因为我希望我的数据注释仍然有效。 这是我的ASP.NET MVC版本的基本表单示例(注意我有asp-for和asp-validation-for set for everything): Basic Info Location Contact Info 例如,当用户单击“下一步”时,我希望“名称”字段进行validation。 当用户在步骤2中单击下一步时,我希望City字段进行validation,依此类推……我习惯一次提交单个表单并允许ASP.NET MVC自动validation,在这种情况下我需要在实际提交之前要求它validation几个不同的时间。 这是我的JS: var form = $(“#example-form”); form.validate({ errorPlacement: function errorPlacement(error, element) { element.before(error); }, rules: { confirm: { equalTo: “#password” } } }); form.children(“div”).steps({ headerTag: “h3”, bodyTag: “section”, transitionEffect: “slideLeft”, onStepChanging: function(event, currentIndex, newIndex) […]

jqueryvalidation未加载requirejs

我在RequireJS中有一个主模块: require([ ‘jquery’, ‘jquery.validate’, ‘jquery.validate.unobtrusive’ ], function ($) { $(document).ready(function () { var validator = $(“form”).validate(); if ($(“#txtFirstName”).val() !== “”) validator.element(“#txtFirstName”); }); }); 当我加载此页面时,出现JavaScript错误: TypeError:$(…)。validate不是函数var validator = $(“form”)。validate(); ** 我现在不知道为什么? 加载所有脚本:

jQuery – 如何使用jQuery Validation插件validation出生日期?

我想使用jQuery Validation插件validation输入(出生日期),但它必须采用“dd / mm / yyyy”格式,并且在年份日期超过2002年时也不会validation。 因此,当日期为“dd / mm / yyyy”且年份超过“2002”时,日期有效

在TinyMCE编辑器中使用jQuery Validate插件

我正在使用jQuery的Validate插件实现客户端validation,并简要介绍了使用TinyMCE编辑器组件的表单字段。 这会在我的表单字段的包含标记下呈现一个非常复杂的控制树,包括实际编辑区域的iframe和textarea元素。 我无法直接访问textarea ,所以在调用.validate()之前添加’required’属性,如下所示: jQuery(function() { jQuery(“#wpsm_body”).addClass(“required”); jQuery(“#wpsm-send-mail”) .validate( { errorContainer : “#wpsm-top-error-container, #wpsm-bottom-error-container”, errorLabelContainer : “#wpsm-top-error-container ul”, wrapper : “li”, messages : { wpsm_from : “The message has no ‘From’ address. The administrator can set a default for this on the SuperMail ‘Settings’ page.”, wpsm_subject : “The message has no subject.”, wpsm_body : “The […]

JQueryvalidation未validation

我正在尝试使用JQueryvalidation器插件来validationrails应用程序,但它既没有抛出任何错误也没有validation任何东西。 我不知道我的代码还有什么问题 – 任何帮助都将不胜感激! $(document).ready(function() { $(“.theform”).validate({ rules: { name: { required:true, minlength:2, maxlength:50 }, email: { required: true, email: true, minlength:2, maxlength:50 }, phone_number: { required: true, phoneUS: true, minlength:9, maxlength:20 } }, messages: { name: { required: “Please provide your name”, minlength: “Too few characters!”, maxlength: “Too many characters!” }, email: { required: […]