validator $.validator.methods[method] is undefined

前端 未结 1 1853
鱼传尺愫
鱼传尺愫 2020-12-09 05:10

I have this validator form code I have inherited which I am getting this error:

$.validator.methods[method] is undefined 

and under that it

相关标签:
1条回答
  • 2020-12-09 05:39

    You are getting this error because you're calling a non-existent rule...

    rules: {
        //other rules,
        interest2: {
            notEqualTo: "#interest"
        },
    }
    

    notEqualTo is not a valid rule included within this plugin. You must remove it or create a new rule called notEqualTo by using the plugin's built-in addMethod() method. Something like this...

    jQuery.validator.addMethod('notEqualTo', function(value, element, param) {
        return value != jQuery(param).val();
    }, 'Must not be equal to {0}.' );
    
    0 讨论(0)
提交回复
热议问题