Prevent multiple submit of your form with jQuery

Multiple submissions of the same form is definitely one of the most common problem seen when working with web forms. Here’s a super useful piece of code to prevent multiple submissions of the same form.
[javascript]
$(document).ready(function() {
$(‘form’).submit(function() {
if(typeof jQuery.data(this, "disabledOnSubmit") == ‘undefined’) {
jQuery.data(this, "disabledOnSubmit", { submited: true });
$(‘input[type=submit], input[type=button]’, this).each(function() {
$(this).attr("disabled", "disabled");
});
return true;
}
else
{
return false;
}
});
});
[/javascript]
Snippet : Source

Leave a Reply