前面已經指出的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