Prevent double submit
Prevent double submit
I have used jquery first time in my project.
i have implemented most stuff as needed but now i am faced with a problem of double submit.
Right now after i validate the form successfully i block the window with a popup div, but the prob i am facing is that even before the form is validated the submit button is pressed twice.
i a tried disabling the submit button on its click event and reenable it when some error occurs but the prob is i reenabled it in the errorplacement function, but here the prob is this event does not fire in case the form is submitted again with same error state as it was last time, in that case the error placement function never executes again and the submit button remains disabled.
so if there is any other way that i could handle it it would be greatly helpful
here the submit button is disabled
- $("#submit").click(function() {
$("#submit").attr("disabled","disabled");
});
here it is re-enabled in case if validation fails
- $("#changePassword").validate({
- errorPlacement: function(error, element) {
error.insertAfter(element);
$("#submit").removeAttr("disabled");
}
- });