In the code from this answer:
$.validator.addMethod('lessThanEqual', function(value, element, param) {
return this.optional(element) || parseInt(value) <= parseInt($(param).val());
}, "The value {0} must be less than {1}");
What is the meaning of {0} and {1}? What is the rule of thumb in Javascript to define those parameter replacements?
So based on the comments, I want to further ask in order to pass {0} and {1} here.
What is the syntax I have to use for validation function lessThanEqual.
thank you
There isn’t a “special” meaning, they’re just tokens that the validator plugin replaces when displaying the message, numerically referring to the parameters for the rule.
Specifically, this is happening in the plugin:
So
{0}refers to the first parameter,{1}the second and so on. Here’s that format function as it is in jQuery.validate 1.7: