I need to validate an array of input text elements (mileage): For example:
-
You have to loop through in these cases, like this:
$(document).ready(function() {
$("#form1").validate({
submitHandler: function(form) {
form.submit();
}
});
$("#form1 input[name='mileage']").each(function() {
$(this).rules("add", { required: true });
});
});
.rules() only affects the first match, so you need a .each() on there to loop through and add any rules to all matches.
- 热议问题