简体   繁体   English

添加自定义jquery.validation方法会导致Uncaught TypeError:无法读取未定义的属性“ call”

[英]adding a custom jquery.validation method results in Uncaught TypeError: Cannot read property 'call' of undefined

I am battling to get jquery.validation to work with a custom method. 我正在努力让jquery.validation与自定义方法一起使用。

I am trying this 我正在尝试

 $.validator.addMethod("validateMe", function (value, element) {
        alert("validate");
    });
$( "#myTextBox" ).rules( "add", {
    validateMe: true
  });

I am using jquery.validate v1.12 but when trying to validate I get an error of 我正在使用jquery.validate v1.12,但是尝试验证时出现错误

Uncaught TypeError: Cannot read property 'call' of undefined 

Am I missing something here? 我在这里想念什么吗?

If anyone else has the same problem it turns out I wasnt providing a message 如果其他人有同样的问题,结果我没有提供任何信息

 $.validator.addMethod("validateMe", function (value, element) {
    alert("validate");
 }, 'Hello message!');

did the trick 做到了

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未捕获的类型错误:无法使用 jQuery 验证读取未定义的属性“调用” - uncaught TypeError: Cannot read property 'call' of undefined using jQuery validation 未捕获的类型错误:无法读取未定义的属性“结果” - Uncaught TypeError: Cannot read property 'results' of undefined 未捕获的类型错误:无法读取未定义的属性“调用” - Uncaught TypeError: Cannot read property 'call' of undefined jquery 验证接受方法 - TypeError:无法读取未定义的属性“调用” - jquery validate accept method - TypeError: Cannot read property 'call' of undefined 未捕获的TypeError:无法读取未定义的属性“结果”-YQL - Uncaught TypeError: Cannot read property 'results' of undefined - YQL 未捕获的类型错误:尝试在 Vuejs 中调用 onchange() 方法时无法读取未定义的属性“应用” - Uncaught TypeError: Cannot read property 'apply' of undefined when trying to call onchange() method in Vuejs Select2 Uncaught TypeError:无法读取未定义的属性“调用” - Select2 Uncaught TypeError: Cannot read property 'call' of undefined Webpack Uncaught TypeError:无法读取未定义的属性“调用” - Webpack Uncaught TypeError: Cannot read property 'call' of undefined 未捕获的类型错误:无法读取未定义的 javascript .filter() 的属性“调用” - Uncaught TypeError: Cannot read property 'call' of undefined javascript .filter() JQuery 自动完成:未捕获的类型错误:无法读取未定义的属性“值” - JQuery autocomplete: Uncaught TypeError: Cannot read property 'value' of undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM