Last active
August 29, 2015 13:56
-
-
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.
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
(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