onkeyup
is enabled by default so you do not need to set it to true
. If you do, you break the functionality already built into the plugin.
You have three options:
1) Leave the onkeyup
option out of .validate()
. This keeps onkeyup
functionality enabled by default. (edit: "by default" means that validation occurs on every "key-up" event only after the field is initially validated by another event.)
DEMO: http://jsfiddle.net/ZvvTa/
2) onkeyup
can be set to false
to disable this option.
DEMO: http://jsfiddle.net/ZvvTa/1/
3) Replace onkeyup
with your own callback function to modify how it operates. (Demo uses default function)
DEMO: http://jsfiddle.net/ZvvTa/2/
Below is the default, unmodified, onkeyup
callback function:
onkeyup: function( element, event ) {
if ( event.which === 9 && this.elementValue(element) === "" ) {
return;
} else if ( element.name in this.submitted || element === this.lastElement ) {
this.element(element);
}
}
See: http://docs.jquery.com/Plugins/Validation/validate#toptions
EDIT:
By default, the plugin does not do any "key-up" validation until after the field is initially validated by another event. ("Lazy" validation)
So here is a more properly modified version of the onkeyup
callback function that will provide immediate onkeyup
validation. ("Eager" validation)
DEMO: http://jsfiddle.net/QfKk7/
onkeyup: function (element, event) {
if (event.which === 9 && this.elementValue(element) === "") {
return;
} else {
this.element(element);
}
}