Ticket #4022 (closed bug: invalid)
[validate] additional-method.js
| Reported by: | hackzilla | Owned by: | joern |
|---|---|---|---|
| Priority: | minor | Milestone: | 1.3.1 |
| Component: | plugin | Version: | 1.3.1 |
| Keywords: | validate additional methods | Cc: | |
| Blocking: | Blocked by: |
Description
IN additional-method.js, there are three functions at the top:
jQuery.validator.addMethod("maxWords", function(value, element, params) {
return this.optional(element) value.match(/\b\w+\b/g).length < params;
}, "Please enter {0} words or less.");
jQuery.validator.addMethod("minWords", function(value, element, params) {
return this.optional(element) value.match(/\b\w+\b/g).length >= params;
}, "Please enter at least {0} words.");
jQuery.validator.addMethod("rangeWords", function(value, element, params) {
return this.optional(element) value.match(/\b\w+\b/g).length >= params[0] && value.match(/bw+b/g).length < params[1];
}, "Please enter between {0} and {1} words.");
The error message however doesn't substitue {0} with the parameter.
They are missing jQuery.format
Here is what is working for me.
jQuery.validator.addMethod("maxWords", function(value, element, params) {
return this.optional(element) value.match(/\b\w+\b/g).length < params;
}, jQuery.format("Please enter {0} words or less."));
jQuery.validator.addMethod("minWords", function(value, element, params) {
return this.optional(element) value.match(/\b\w+\b/g).length >= params;
}, jQuery.format("Please enter at least {0} words."));
jQuery.validator.addMethod("rangeWords", function(value, element, params) {
return this.optional(element) value.match(/\b\w+\b/g).length >= params[0] && value.match(/bw+b/g).length < params[1];
}, jQuery.format("Please enter between {0} and {1} words."));
Appologies if this the wrong place.
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
