Oddish wrote:
I just upgraded the validation plugin to 1.0 final from beta 2 and now
I get this on one of my forms:
Error: jQuery.validator.getLength is not a function
The line where the error occurs is the second of the three lines
below:
jQuery.validator.addMethod("validPhoneNr", function(value, element,
param) {
return /^\+{0,1}[\d\- ]+$/.test(value) ||
jQuery.validator.getLength(value, element) == 0;
},"");
Does anyone know if this function has changed or been replaced?
Its scope has changed, just replace "jQuery.validator" with "this":
jQuery.validator.addMethod("validPhoneNr", function(value, element, param) {
return /^\+{0,1}[\d\- ]+$/.test(value) || this.getLength(value,
element) == 0;
},"");
To make that method optional, eg. more useful in combination with required:
jQuery.validator.addMethod("validPhoneNr", function(value, element, param) {
return this.required(element) || /^\+{0,1}[\d\- ]+$/.test(value) ||
this.getLength(value, element) == 0;
},"");
--
Jörn Zaefferer
http://bassistance.de