问题
How I can call a validate method created with jQuery.validator?
Example:
jQuery.validator.addMethod("functionA", function(value, element) {
if($.trim(value)==""){
return false;
}
return true;
}, "MSG A");
jQuery.validator.addMethod("functionB", function(value, element) {
return jQuery.functionA(); //<--- How do I do it?
}, "MSG B");
回答1:
Methods added with addMethod are inside the $.validator.methods object. You can call functionA like this:
jQuery.validator.addMethod("functionB", function(value, element) {
return jQuery.validator.methods.functionA.call(this, value, element);
}, "MSG B");
来源:https://stackoverflow.com/questions/9038423/jquery-validator-call-method-added-with-addmethod