Last active
January 18, 2020 09:40
-
-
Save toddlahman/6302114 to your computer and use it in GitHub Desktop.
Prevent Duplicate Form Submissions with jQuery
This file contains 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
jQuery(function() { | |
$("form").submit(function() { | |
// submit more than once return false | |
$(this).submit(function() { | |
return false; | |
}); | |
// submit once return true | |
return true; | |
}); | |
}); | |
/* or */ | |
jQuery('form').submit(function(){ | |
$(this).find(':submit').attr( 'disabled','disabled' ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks! That's really helpful.