Created
March 3, 2014 08:45
-
-
Save ariera/9320891 to your computer and use it in GitHub Desktop.
jQuery.lockSubmit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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