views:

16

answers:

1

Hi,

According to the documentation for the JQuery validation plugin:

the validation is lazy: Before submitting the form for the first time, the user can tab through fields without getting annoying messages

Is there any way to display the messages as the user tabs through the form?

Cheers

A: 

You can override the default onfocusout to do more eager/pre-submit validation you want, like this:

$(function() {
  $("form").validate({
    rules: { ...rules... },
    messages: { ...messages... },
    onfocusout: function(element) { $(element).valid(); }
  });
});

The default onfocusout looks like this, disabling the blur validation until after it's been submitted once:

onfocusout: function(element) {
  if ( !this.checkable(element) && (element.name in this.submitted || !this.optional(element)) ) {
    this.element(element);
  }
}
Nick Craver