简体   繁体   English

未捕获的TypeError:对象# <error> 没有方法“呼叫”

[英]Uncaught TypeError: Object #<error> has no method 'call'

Using the jquery validate plugin, I want to show/hide error only when the element's blur event is called, dont want to show error message as you type. 使用jquery validate插件,我只希望在调用元素的blur事件时才显示/隐藏错误,而不想在键入时显示错误消息。 To fix this I tried 为了解决这个问题,我尝试了

$('#form').validate({
    onfocusout: true,
    onkeyup: false
});

but as soon I click outside any element it throws error 但是当我在任何元素之外单击时,都会引发错误

Uncaught TypeError: Object #<error> has no method 'call' 

its onfocusout not onfoucusout , change to: onfocusout而不是onfoucusout ,更改为:

$('#form').validate({
    onfocusout: function(element) { $(element).valid(); },
    onkeyup: function(element) { $(element).valid(); }
});

As already pointed out by Sudhir, you've misspelled the onfocusout option. 正如Sudhir所指出的那样,您拼写了onfocusout选项。

Additionally, the onfocusout and onkeyup options are already enabled by default in this plugin. 另外,此插件默认已启用onfocusoutonkeyup选项。

You only have two choices... 您只有两种选择...

1) If you want to disable onfocusout or onkeyup , you would set them to false ... 1)如果要禁用onfocusoutonkeyup ,可以将它们设置为false

$('#form').validate({
    onfocusout: false, // disable validation on blur
    onkeyup: false     // disable validation on key-up
});

2) If you want to modify the default behavior of onfocusout or onkeyup , you would set them to your custom function... 2)如果要修改onfocusoutonkeyup的默认行为,则可以将它们设置为自定义函数...

$('#form').validate({
    onfocusout: function(element, event) {
        // your custom callback function for blur event
    },
    onkeyup: function(element, event) {
        // your custom callback function for key-up event
    }
});

Otherwise, if you simply want the default behavior of the onfocusout or onkeyup options, leave them out of the .validate() call entirely. 否则,如果仅希望onfocusoutonkeyup选项的默认行为, 请将其完全排除onfocusout .validate()调用之外。 As per documentation , setting these to true "is not a valid value" and will break the plugin. 根据文档 ,将其设置为true “不是有效值”,并且会破坏插件。

$('#form').validate({
    // onfocusout: true, // <- remove this line, true value is not valid
    // onkeyup: true     // <- remove this line, true value is not valid
});

Documentation: 说明文件:

onfocusout 聚焦
Type: Boolean or Function() 类型:布尔值或Function()
Validate elements (except checkboxes/radio buttons) on blur . 验证模糊元素(复选框/单选按钮除外) If nothing is entered, all rules are skipped, except when the field was already marked as invalid. 如果未输入任何内容,则将跳过所有规则,除非该字段已被标记为无效。 Set to a Function to decide for yourself when to run validation. 设置为“功能”可自行决定何时运行验证。 A boolean true is not a valid value . 布尔值true不是有效值


onkeyup 按键
Type: Boolean or Function() 类型:布尔值或Function()
Validate elements on keyup . 验证keyup上的元素 As long as the field is not marked as invalid, nothing happens. 只要该字段未标记为无效,就不会发生任何事情。 Otherwise, all rules are checked on each key up event. 否则,将在每个按键事件上检查所有规则。 Set to false to disable. 设置为false以禁用。 Set to a Function to decide for yourself when to run validation. 设置为“功能”可自行决定何时运行验证。 A boolean true is not a valid value . 布尔值true不是有效值

暂无
暂无

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

相关问题 未捕获的TypeError:对象# <LanParties> 没有方法“呼叫” - Uncaught TypeError: Object #<LanParties> has no method 'call' 未捕获的TypeError:对象# <error> 没有办法 - Uncaught TypeError: Object #<error> has no method 骨干-未捕获的TypeError:对象[object Object]没有方法&#39;call&#39; - Backbone - Uncaught TypeError: Object [object Object] has no method 'call' handlebars.js未捕获的TypeError:Object# <Object> 没有方法&#39;呼叫&#39; - handlebars.js Uncaught TypeError: Object #<Object> has no method 'call' 我不断收到Uncaught TypeError:函数调用期间对象[object global]没有方法错误 - I keep receiving Uncaught TypeError: Object [object global] has no method error during function call JavaScript错误:未捕获的TypeError:对象[object Object]没有方法&#39;src&#39; - Javascript error: Uncaught TypeError: Object [object Object] has no method 'src' JQtouch错误:未捕获的TypeError:对象[object Object]没有方法&#39;live&#39; - JQtouch error : Uncaught TypeError: Object [object Object] has no method 'live' 未捕获的TypeError:对象没有方法“打开” - Uncaught TypeError: Object has no method 'on' 未捕获的TypeError:对象local.process没有方法“调用” - Uncaught TypeError: Object local.process has no method 'call' 奇怪的错误:未捕获的TypeError:对象[object HTMLElement]没有方法&#39;getAttribute&#39; - Weird error: Uncaught TypeError: Object [object HTMLElement] has no method 'getAttribute'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM