jQuery Disable On Submit Plugin

Posted under jQuery on March 15, 2009.

This small plugin disables form buttons when the user submits the form. This prevents novice users from double clicking the button and submitting the form twice.

Here is example use of the plugin:

$(function(){
  $('form').disableOnSubmit();
});

The above code would apply the effect to all forms. You can try the live demo here.

Additionally, you can add a second optional parameter to the function that tells the plugin exactly what input elements within the form you want disabled.

$(function(){
  $('form').disableOnSubmit('input[type=submit],input[type=button],textarea,button');
});

Download the plugin with example here.

This plugin has been tested on IE6+, FF3, Opera 9, and Safari 4.

Comment

See what others have to say on this topic, or add your own two cents.