views:

302

answers:

1

Hello

I am using the jquery validation plugin

I have the following code in an onClick function of my form submit button.

onClick="parent.$.fn.fancybox.close();parent.location.reload();"

When the form detects a field is not filled in, it successfully halts submission of the form, however the onClick event still fires.

Is there a way to get this event to also halt firing when this occurs?

Thanks,

Tim

+1  A: 

Use the submit handler function with the validation plugin instead of an onclick:

$("#myform").validate({
 submitHandler: function(form) {
   parent.$.fn.fancybox.close();
   parent.location.reload();
   form.submit();
 }
});

The submitHandler gets triggered after a successful validation of the form.

Parrots
Thank-you! Very much appreciated
Tim