Tag: jquery validate

将jQueryvalidation插件消息放在新行中

我正在使用jQuery Validate。 这一切都正常工作,但当有更多的消息时,消息显示在另一个旁边。 我需要消息显示在他们自己的行中。 $(“#myform”).validate({ errorLabelContainer: “#messageBox”, debug: false, rules: { name: “required”, email: { required: true, email: true, }, password: { required: true, minlength: 8 }, }, messages: { name: “Please enter your name.”, email: “Please enter a valid email address.”, password: “Please enter at least 8 password characters.”, } }); Current display: Message1Message2Message3 […]

使用jQuery Validate的invalidHandler事件

我需要在validation时添加一个包含在select元素周围的div的类。 $(“#Form”).validate({ invalidHandler: function (form, validator) { $(“[id$=’_DropDownList’]”).each(function () { // How do I figure out if $(this) is valid or invalid? // Add the class below if invalid. $(this).parent().addClass(“error”); }); } });

如何使用默认值validation可选字段?

我对以下示例进行了一些更改: http://docs.jquery.com/Plugins/validation#Example * { font-family: Verdana; font-size: 96%; } label { width: 10em; float: left; } label.error { float: none; color: red; padding-left: .5em; vertical-align: top; } p { clear: both; } $(document).ready(function(){ $(“#commentForm”).validate(); }); A simple comment form with submit validation and default messages Comment 我知道如何为必填字段Name,Email和Comment添加自定义validation方法。 但我只是不知道如何validation可选的归档URL。 我到处搜索都无济于事! 任何帮助是极大的赞赏! 绝望

JQuery CreditCardvalidation器扩展

我正在使用Jquery Validator我的挑战是当用户更新他们的个人资料信息时。 但不改变他们的CC。 在更新页面中,我只显示4 * * ** * 1111 因此,如果使用以下validation失败:(下面的代码片段) $(“#profile-form”).validate({ rules: { ccnum: { required: true, creditcard: true }, exp_year: { ccDate: true}, exp_month: { ccDate: true} } 但是如果用户输入一个新的CC号码,它就会按照它想要的那样做。 所以我的问题是,如果用户想要更新其他内容并且不接触CC卡,我该怎么办? 有什么想法/建议吗?

根据需要设置reCaptcha字段

我使用新的reCaptcha和jQuery Validate插件。 validation插件适用于我的表单但不幸的是它不适用于reCaptcha。 我试图让它在下面工作: HTML: 使用Javascript: recaptcha: { required: true } 但它没有奏效。 有谁知道如何解决这一问题。 我只需要默认的这个字段是必需的错误信息。

JQuery Validate – 使用函数重置表单,resetForm()将不起作用

我正在使用JQuery Validator,我在stackoverflow中看到了很多解决方案,将所有validation放在“var”中然后使用这个“var”.resetForm()来重置对象,但这不起作用,这是我的JSFiddle用我的榜样。 我的意图是:使用相同的Form,两种类型的块,内部有不同的输入,当其中一个块发生变化时,我调用一个方法来重置validation,这样我可以在尝试提交时再次重用Validate。 var validate = $(‘#cad_principal’).validate({ errorLabelContainer: $(‘.form_validate_message’), wrapper:’li’, rules:{ cad_pf_cpf:{required:true, minlength:11} }, messages:{ cad_pf_cpf:{required:”O campo CPF precisa ser preenchido.”, minlength:”O campo CPF deve conter no mínimo 11 caracteres.”} }, submitHandler: function(form) { $(form).submit(); } }); function cancelForm(){ validate.resetForm(); }

显示来自jQuery的错误在不同的容器中validation

我有一些表单,我正在使用jQuery Validate插件进行validation。 下一个代码示例,工作正常: $(document).ready(function(){ $(“#transactionform”).validate({ rules: { ‘cliente[nombre]’: { required: true, minlength: 5 }, ‘cliente[id]’: { required: true } } }); }); 在这种forms中,’cliente [nombre]’是一个简单的文本输入,’cliente [id]’是一个必须由一些javascript函数填充的隐藏字段。 实际上,validation错误显示在相应字段旁边,其中包括隐藏字段。 我想要的是有一个特殊的div用于显示隐藏输入的validation错误,并使用相应的标签显示非隐藏的输入错误(就像现在一样)。

当字段已经填充时,jQuery Validate有时不起作用

我的页面中有一个更新表单,所有文本框都已填入用户的信息。 我在我的网站上使用了jquery-validation插件。 当表单没有任何默认值时,此插件可以正常运行而不会出现任何错误。 在我的表单中,有时错误消息显示我不知道发生了什么。 当我尝试删除文本框的某个值时,表单的初始加载示例将显示错误消息。 但是当我尝试删除其他文本框的值并再次测试错误消息显示的第一个文本框时。 你能帮助我吗? 这是我的代码: profile.php PROFILE UPDATE ‘member-update’, ‘role’ => ‘form’)); ?> Desired Username <input type="text" class="form-control input-sm show_popover" name="username" placeholder="username" data-toggle="popover" data-trigger="focus" data-placement="top" data-content="This will be use for security purposes." value="” /> Email Address <input type="text" class="form-control input-sm show_popover" name="email" placeholder="avjunky@email.com" data-toggle="popover" data-trigger="focus" data-placement="top" data-content="This will be use to email […]

jQuery Validate,Select2和Bootstrap 3 Popovers – 如何将Popover绑定到Select2的父元素而不是隐藏的选择元素

我已经实现了使用Bootstrap 3的Popovers来显示validation错误消息的优秀方法,并且在大多数情况下它运行良好 – 除了隐藏或替换的元素,如Select2或CKEditor。 弹出窗口正确地定位在常规元素(如输入和正常选择)上,但不是选择2增强的选择。 我创建了一个Sparky固定的小提琴,所以它实际上有效: http : //jsfiddle.net/jemxtthb/4/ $(“#noticeSentTo”).select2(); var validator = $(“#documentAdmin”).validate({ debug: true, ignore: “”, showErrors: function(errorMap, errorList) { $.each(this.successList, function(index, value) { return $(value).popover(“hide”).parents(“.form-group”).removeClass(‘has-error’).addClass(‘has-success’); }); return $.each(errorList, function(index, value) { var _popover; _popover = $(value.element).popover({ trigger: “manual”, placement: “auto top”, content: value.message, container: “body”, template: “” }); _popover.data(“bs.popover”).options.content = value.message; return […]

Bootstrap 3validation

我想我几乎有Bootstrapvalidation工作,但它似乎有缺陷或我错过了一些东西。 使用输入组时,如何使图标显示在文本字段中。 另一个问题是,当它出错并且用户修复它时,x图标仍然存在,而不是复选框。 的jsfiddle $(‘form’).validate({ rules: { field1: { minlength: 3, maxlength: 15, required: true }, field2: { minlength: 3, maxlength: 15, required: true } }, highlight: function(element) { $(element).closest(‘.form-group’).removeClass(‘has-success’).addClass(‘has-error’) $(element).next(‘span’).removeClass(‘glyphicon-ok’).addClass(‘glyphicon-remove’); }, unhighlight: function(element) { $(element).closest(‘.form-group’).removeClass(‘has-error’).addClass(‘has-success’) $(element).next(‘span’).removeClass(‘glyphicon-remove’).addClass(‘glyphicon-ok’); }, //errorElement: ‘span’, errorClass: ‘help-block’, errorPlacement: function(error, element) { if(element.parent(‘.input-group’).length) { error.insertAfter(element.parent()); } else { error.insertAfter(element); } } […]