Side navigation
#4022 closed bug (invalid)
Opened January 29, 2009 09:56AM UTC
Closed February 05, 2010 08:35PM UTC
[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: | |
Blocked by: | Blocking: |
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.