At first, i have searched many but no article solved my problem.
This article make me know that using quote to validate array inputs.
My problem is how to validating length of array inputs. For more detail, plz read more bellow
In my HTML:
<form id="demo-form">
<input type="text" name="product[]" id="p1">
<input type="text" name="product[]" id="p2">
<input type="text" name="product[]" id="p3">
<input type="text" name="product[]" id="p4">
<input type="submit value="submit">
</form>
This requires user has to enter at lease 2 products
Script
jQuery("#demo-form").validate({
rules: {
'product[]': {
required: true,
minlength: 2 //this only use to validate length of string inputed, not length of array products
}
},
});
How to validate length of array products?
Thanks