Skip to content

Instantly share code, notes, and snippets.

@boye
Last active August 29, 2015 13:56
Show Gist options
  • Save boye/9110888 to your computer and use it in GitHub Desktop.
Save boye/9110888 to your computer and use it in GitHub Desktop.
Simple snippet to disable submit buttons when submitting a form to prevent multiple submits. This is especially useful when the user is on a slow connection.
(function (d) {
var f = d.getElementsByTagName('form'),
i = f.length;
while (i--) {
f[i].addEventListener('submit', function () {
this.querySelector('[type="submit"]').disabled = 1;
}, false);
}
}(document));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment