Reputation: 11
I'm using jQuery Validation Engine (https://github.com/posabsolute/jQuery-Validation-Engine) to validate my form. I want to disable submit button to prevent multiple submits if validation is true. I couldn't achieve this with callback functions.
Upvotes: 1
Views: 2173
Reputation: 12038
I typically do this:
$('#theform').submit(function() {
$('#submitbutton').attr('disabled', 'disabled');
});
Of course if you are doing any onsubmit validation that fails you have to reenable the button:
$('#submitbutton').removeAttr('disabled');
Upvotes: 0
Reputation: 2790
I always do this trick
$('#yourform').submit(function() {
if($(this).hasClass('blockSubmit')) return false;
$(this).addClass('blockSubmit');
/*
* organizing data, requesting, responding, et cetra cetra...
*/
$(this).removeClass('blockSubmit');
});
Upvotes: 1