jquery - How to enable submit event in form if validation fails -
shopping cart form contains validation form ajax submit. if validation fails, alert() box appears , submit cancelled return false
if validation fails, submit method not called anymore. subsequent clicks button ignored.
only first click in green lisa ostukorvi
button causes alert box. subsequent clicks ignored, submit() event not fire. occurs in ie10, firefox & chrome. how fix this?
<script> var request; $(function() { $(".browse-addtocart-form").submit(function(event){ if (request) { request.abort(); } var $form = $(this); var $inputs = $form.find("input, select, button, textarea"); var serializeddata = $form.serialize(); var q = parseint(this.quantity.value, 10); if(isnan(q) || q === 0){ alert('fill quantity'); $(this.quantity).focus(); // todo: why causes submit event not occur on subsequent clicks: return false; } request = $.post('/addtocart', serializeddata ); return false; }); }); </script> <form class='browse-addtocart-form' action="/addtocartpost" method="post"> <input type="submit" value="add cart" class='button green small bigrounded' /> </form> </html>
jquery, jquery-ui, asp .net mvc2 used.
hi should use click function $("#submitid").click(function () { /* code*//}); , give submit botton id