jquery-validate

Validating several fields with the same name using jQuery Validate

前提是你 提交于 2019-12-17 17:11:06
问题 I have an HTML form that I'm processing with Perl CGI, like so: <form action="process.cgi" id="main"> <input type="text" name="foo" class="required" /> <input type="text" name="foo" class="required" /> <input type="text" name="foo" class="required" /> </form> And I'm validating it with the jQuery Validation plugin. Trouble is, when I call $('#main').valid() , it only checks that the first field is non-empty. How to I get it to check all the fields? 回答1: OFFICIAL DOCUMENTATION:

Jquery Validation Plugin digits that aren't required not working

一笑奈何 提交于 2019-12-17 17:11:04
问题 I'm trying to setup a "digit" field using the jQuery Validation plugin The problem is I don't want the digit field to be required, I just want to validate it as digits only, if someone does enter anything into it. Here is my code, if I remove the "required: true," part, the field no longer throws up an error if I enter text into it and the form gets passed. $('.js-validate-form').validate({ rules: { phoneNumber: { digits: true } } }); And my HTML <input type="number" name="phone" id="phone"

jQuery Validation need to execute same validation twice

亡梦爱人 提交于 2019-12-17 17:10:19
问题 I am working in a form which the user has to fill in two steps, first step he must give his name and email and in the second he must give his chosen password, so I have to execute a validation in the same form twice, it's succesful in the first step, but in the second it is just simple ignored and the form is being submited. This is the js code: jQuery(document).ready(function() { jQuery('#form_wk_new_user').submit(function() { if(jQuery('#form_wk_step_1').css('visibility') == 'visible') {

Validate dynamic field jquery

▼魔方 西西 提交于 2019-12-17 16:54:43
问题 Good afternoon, I came across the following question. I'm using the jQuery Validation plugin to validate my form v1.13.0 client side. Is working just fine. But the problem I can not solve it is: I have a field name "product []", which is an array. I may have one or I may have 20 products in this array. Here is my Code: data_emissao: {required: true}, forma_pagamento: {required: true}, produto[]: {required: true}, // tried this with no sucess Anyone ever run into this problem? 回答1: Two issues.

jQuery Validation plugin with a custom attribute [closed]

不羁的心 提交于 2019-12-17 16:31:34
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I want to use the jQuery Validation plugin with this HTML: <input data-validators="required" name="X2aasNr" type="text" value="Nedas" class="cleared" id=""> As you can see, I use a custom attribute named data-validators . How can I use the jQuery Validation plugin for this case? 回答1: Quote OP: <input data

jquery validation with ajax call

ぐ巨炮叔叔 提交于 2019-12-17 16:21:31
问题 I am using the jquery validation and i need to validate an email. I use $("#myForm").validate({ rules: email: { required: true, email: true } }) SO FAR so good. The problem is that i need to make an ajax call to verify if given email already exist.If exist display message "This email already exits.Please selecte other". Can anyone help me implement this. 回答1: remote: "/some/remote/path" That path will be passed the value of the field in a $_GET. so.. what actually gets called in your case

JQuery Validate Dropdown list

吃可爱长大的小学妹 提交于 2019-12-17 15:53:49
问题 I'm using the validation plugin from here. I'm trying force the user to select an option in the drop down list so here's my html for the list: Select the best option<br/> <select name="dd1" id="dd1"> <option value="none">None</option> <option value="o1">option 1</option> <option value="o2">option 2</option> <option value="o3">option 3</option> </select> <br/><br/>​ And here's the the jquery validation stuff: $("#everything").validate({ onsubmit: true, rules: { dd1: { required: { depends:

Validate subset of a form using jQuery Validate plugin

耗尽温柔 提交于 2019-12-17 15:46:24
问题 My HTML form has a number of divs that are the steps of a wizard. Upon clicking a "next" button I want to validate just the active div. I'm using the jQuery.Validate.js plugin. Each div has an ID, so I want a way to say something like: wizardForm.validate().element('#first-step :input') but this only validates the first input, not all of them. How can I validate all inputs within a div? 回答1: Taking what jAndy suggested, I created this helper function: jQuery.validator.prototype.subset =

JQuery validation-select required if checkbox checked

你说的曾经没有我的故事 提交于 2019-12-17 15:37:43
问题 using jquery I want to make a selection from a select box required (ie it can't be left as the blank default) if a particular checkbox is ticked. My code: $(document).ready(function(){ $("#myForm").validate({ rules: { myDropDown: { required: { depends: function(element) { return $("#myCheckbox:checked") } } } } }) }) The html: <input type="checkbox" name="myCheckbox" id="myCheckbox" value="1"> <select name="myDropDown" id="myDropDown"> <option value="" selected></option> <option value="1"

select2 and jquery validation not working properly

笑着哭i 提交于 2019-12-17 14:58:49
问题 Trying to use validation on select2 with a few issues : the error message will show, but it will not remove when a valid entry is entered. I am loading an initial value which works fine... the validator, however, does not recognize the value and tells me it is invalid... I have to manually type in the same value and then it validates, but still does not remove the error class/message showing it is valid. form : <div class="col-md-12 margin-bottom-30 form-group"> <div class="input-modal-group"