4

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 Answer 1

9

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");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.