I'm trying to add custom form validators. And I'm stuck with message customizing issue.
Let's say I want to check if field value does not exceeds max allowed value. I know that 'Validation Plugin' has a "max" validator already - this is just for sample:
$.validator.addMethod("max-numeric", function(value, element, param) {
var maxValue = $(element).attr("data-max");
return (!maxValue) || maxValue >= value;
}, $.validator.format('Applicants must be older than {0} and younger than {1} years of age'));
$("#data-form").validate({
rules: {
"form.params1.p4":
{
"min-numeric": [5, 6]
}
}
});
I cannot comprehend what is responsible for replacing {0} and {1} in '$.validator.format'. And how to pass those parameters?
UPDATE:
Here is the message I get:
Applicants must be older than true and younger than [object HTMLInputElement] years of age
max-numeric, but you're referencingmin-numericin therulesobject of the.validate()method.$.validator.format()seems to always be totally unnecessary. I've yet to find one instance that breaks when I remove it.