Bug Tracker

Opened 11 years ago

Closed 10 years ago

#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:
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.

Change History (2)

comment:1 Changed 10 years ago by dmethvin

Owner: set to joern

comment:2 Changed 10 years ago by john

Resolution: invalid
Status: newclosed

Please file plugin bugs with the appropriate author on their bug tracker.

Note: See TracTickets for help on using tickets.