I have array of textbox to collect 5 email address. I have used jQuery validate to validate the form to accept email addresses, unfortunately it's validating the first field only.
Though error message comes up for rest of the fields but it allows the form to submit. I need native solution for this issue.
Here is the code snippet:
$(document).ready(function(){
$('#myform').validate({
rules:{
"foo[]":{
required:true,
email:true
}
},
messages:{
"foo[]":{
required:"required",
number:'only numbers!!!'
}
}
});
});
This is the form:
<form method="post" action="" id="myform">
<input type="text" name="foo[]" value="">
<input type="text" name="foo[]" value="">
<input type="text" name="foo[]" value="">
<input type="text" name="foo[]" value="">
<input type="text" name="foo[]" value="">
<input type="image" name="bar">
</form>
namemust be unique to the form for the plugin to work correctly. [jqueryvalidation.org/reference/#link-markup-recommendations]. Check out this question to add same rules to multiple fields.