Skip to content

Instantly share code, notes, and snippets.

@ariera
Created March 3, 2014 08:45
Show Gist options
  • Save ariera/9320891 to your computer and use it in GitHub Desktop.
Save ariera/9320891 to your computer and use it in GitHub Desktop.
jQuery.lockSubmit
//BASED ON:
// Lock a submit button when clicked from being clicking again and change the value of the submit to a message, while preserving the submits name and value in a hidden input.
// License: http://www.gnu.org/licenses/lgpl.txt
// Homepage: http://blog.leenix.co.uk/2009/09/jquery-plugin-locksubmit-stop-submit.html
// Version 1.03
jQuery.fn.lockSubmit = function(options) {
//Default text to change submit button too
// var settings = jQuery.extend({
// submitText: null,
// onAddCSS: null,
// onClickCSS: null
// }, options);
var form = $(this);
var button = $("input[type='submit']", form);
// return button.click(function(){
if (options == null){
button.attr('disabled', 'disabled').addClass("disabled");
setTimeout(function(){
button.removeAttr('disabled').removeClass("disabled");
}, 2000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment