Last active
September 23, 2016 16:05
-
-
Save mhairston/e64549c20212f168102018c4eee8123c to your computer and use it in GitHub Desktop.
Prevent Double Form Submit
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
$('form').on('submit', function(evt) { | |
$('a, button:not([type]), [type="submit"]', this) | |
.prop('disabled', true); | |
$('a').addClass('is-disabled'); | |
}); | |
/* | |
The `is-disabled` class is added for the rare case that a link might | |
be set up to submit a form, since some browsers won't disable a link. | |
a.is-disabled { | |
pointer-events: none; | |
cursor: default; | |
color: #999; | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment