Created
October 30, 2012 16:54
-
-
Save jasontucker/3981506 to your computer and use it in GitHub Desktop.
jQuery - Prevent multiple submit of your form
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
| //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. | |
| $(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; | |
| } | |
| }); | |
| }); | |
| // Source: http://damienalexandre.fr/post/2009/08/02/jQuery-eviter-la-soumission-multiple-d-un-formulaire |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
it works fine for me thank you