The addClassRules
method does not belong inside of .validate()
.
form.validate({
//NAME RULE
rules: {
//profile
first: {
minlength: 2,
required: true
}
}
});
As per documentation, it gets attached to the validator object to create the compound rule that represents the standard rules specified inside.
jQuery.validator.addClassRules("myCompundRule", {
required: true,
minlength: 2
});
Usage is as simple as applying the new class
to your input
.
<input type="text" class="myCompundRule" name="somename" />