JQuery validator: call method added using addMethod

How can I call a validation method created using 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"); 
+4
source share
1 answer

Methods added with addMethod are located inside the $.validator.methods . You can call functionA as follows:

 jQuery.validator.addMethod("functionB", function(value, element) { return jQuery.validator.methods.functionA.call(this, value, element); }, "MSG B"); 
+8
source

Source: https://habr.com/ru/post/1393417/


All Articles