I have two or more text fields and I want to apply the same properties to them, avoiding to write two or more times the same code
This doesn\'t work:
$(\
Try Like this
var ruleSet1 = {
required: true,
minlength: 3,
maxlength: 50
};
$('#form').validate({
rules: {
field_1: ruleSet1,
field_2: ruleSet1,
field_3: ruleSet1
}
});
or do it one by one like the following,
$("#form").validate({
rules:
{
name: { required: true },
surname:{
required: true,
minlength: 3,
maxlength: 50
}
}
});