2012-01-27 4 views
4

jQuery.validator로 생성 된 유효성 검사 메소드를 어떻게 호출 할 수 있습니까?jQuery 유효성 검사기 : addMethod로 호출 메소드가 추가되었습니다.

예 :

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"); 

답변

8

방법은 addMethod 첨가 $.validator.methods는 객체 내에있는. 다음과 같이 functionA 번으로 전화 할 수 있습니다.

jQuery.validator.addMethod("functionB", function(value, element) { 
    return jQuery.validator.methods.functionA.call(this, value, element); 
}, "MSG B"); 
관련 문제