4

I want to create a custom validator method but how can I call its core method but getting error, something like this

jQuery.validator.addMethod("requiredHidden", function (value, element) {
    if ($(element).is(':visible') == false) {
        return true;
    }
    else {
        return jQuery.validator.required(value, element);
    }
}, "*");

error: jQuery.validator.required is not a function

1 Answer 1

4

Try the following:

jQuery.validator.addMethod("requiredHidden", function (value, element) {
    if ($(element).is(':visible') == false) {
        return true;
    }
    else {
        return jQuery.validator.methods.required.call(this, value, element);
    }
}, "*");

See this.

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.