Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery validator: Call method added with addMethod

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");
like image 471
Fabio Avatar asked Jan 18 '23 15:01

Fabio


1 Answers

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");
like image 138
Rocket Hazmat Avatar answered Jan 29 '23 06:01

Rocket Hazmat