Skip to content

Instantly share code, notes, and snippets.

@mhairston
Last active September 23, 2016 16:05
Show Gist options
  • Save mhairston/e64549c20212f168102018c4eee8123c to your computer and use it in GitHub Desktop.
Save mhairston/e64549c20212f168102018c4eee8123c to your computer and use it in GitHub Desktop.
Prevent Double Form Submit
$('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