struts2 - How to suppress Jquery Validation submitHandler when cancel button is clicked? -
here have problem jquery validation plugin , struts2.
i have 3 buttons below in form.
<td><s:submit type="button" value="save" theme="simple" cssclass="valid" /></td> <td><s:submit type="button" value="cancel" theme="simple" action="cancel" cssclass="cancel"/></td> <td><s:submit type="button" value="submit" theme="simple" cssclass="valid"/></td>   when form submitted, validations done using jquery validation. after form submitted, want user confirmation submit form ?
so used submithandler of jquery validate function. when click cancel submithandler getting executed. dont want happened when cancel button clicked. here javascript part.
$(document).ready(function() {      $("#myform").validate({     //some validation rules         submithandler: function(form) {         //this runs when form validated         //my code after submitting form              alert("hello");         } //end of submit handler     });  });   i know simple answer.though please me find people
the root problem form contains 3 submit buttons.  though each 1 has different value, plugin trigger same on each one.
1)  change cancel button type="reset".  plugin ignore type of input (however, html clear form data).
or
2)  move cancel button outside of form.  layout different can place button more precisely using css.
or
3)  leave inside form, block default behavior of submit button using jquery's preventdefault().   must put id on button can target properly.
$('#cancel').click(function(e) {     e.preventdefault();     // else on click });