/ Published in: jQuery

To prevent multiple submit from sending more than one request,
bind the submit event and store a "disabledOnSubmit" data. Next time the event "submit" will be fire, the following jQuery code will return false. All submit buttons are also disabled (nice user feedback).
bind the submit event and store a "disabledOnSubmit" data. Next time the event "submit" will be fire, the following jQuery code will return false. All submit buttons are also disabled (nice user feedback).
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$(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; } }); });
Comments
