前面已经指出的Sudhir,你拼错了onfocusout
选项。
此外,onfocusout
和onkeyup
选项已在此插件中启用默认。
你只有两种选择...
1)如果你想禁用onfocusout
或onkeyup
,你将它们设置为false
...
$('#form').validate({
onfocusout: false, // disable validation on blur
onkeyup: false // disable validation on key-up
});
2)如果你想修改的onfocusout
或onkeyup
的默认行为,你将它们设置为自定义函数......
$('#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
}
});
超视距否则,如果您仅仅希望onfocusout
或onkeyup
选项的默认行为,则完全不会让拨打.validate()
。 As per documentation,将它们设置为true
“不是有效值”并且会破坏插件。
$('#form').validate({
// onfocusout: true, // <- remove this line, true value is not valid
// onkeyup: true // <- remove this line, true value is not valid
});
文档:
onfocusout
Type: Boolean or 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.
onkeyup
Type: Boolean or Function()
Validate elements on 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. Set to a Function to decide for yourself when to run validation. A boolean true is not a valid value.
设置'onfocusout'到TRUE;是_'not有效value'_ [按文档](HTTP ://jqueryvalidation.org/validate)。 – Sparky