views:

12

answers:

1

hi there,

it seems that jquery validate plugin does not come with out of the box, success and failed callback options. how do i manage to launch some custom code when a form's validation fails?

we need to change certain layout elements not related to the fields itself when a player enters invalid data.

hope it is still possible

+3  A: 

These options are included, just not as intuitively named as possible, they're submitHandler and invalidHandler, like this:

$("form").validate({
  invalidHandler: function(form, validator) {
    //this runs when the form is invalid, not submitted
  },
  submitHandler: function(form) {
    //this runs when the form is is valid
  }
});
Nick Craver
oh dear, if that's correct i feel ashamed for my question :) i'm on it right now, will probably work just as i expect it to now :) thanks
Sander
@Sander - welcome!
Nick Craver
seems to work as expected, thanks
Sander