I want to use "jQuery validation plugin" (http://jqueryvalidation.org/) with arrays.
I tried this solution:
Validating array inputs using jquery validation plugin
But it's not working for me: only one element per array is being check.
My HTML is:
<form id="signupForm" method="get" action="">
<fieldset>
<p>
<label for="username">Username</label>
<input name="username[]" type="text">
</p>
<p>
<label for="username">Username</label>
<input name="username[]" type="text">
</p>
<p>
<input class="submit" type="submit" value="Submit">
</p>
</fieldset>
</form>
And my jQuery is:
$("#signupForm").validate({
rules: {
'username[]': "required"
},
messages: {
'username[]': {
required: "Please enter a username"
}
}
});
Here a jsFiddle: https://jsfiddle.net/t14ft1ny/