Skip to content

Instantly share code, notes, and snippets.

Created Jul 1, 2019
What would you like to do?
Prevent multiple submits when clicked a submit button
<form action='/'>
<button class="prevent-multiple-submit" type="submit">Create</button>
function disableButton(event) {'disabled', 'disabled');;
var preventButtons = document.getElementsByClassName('prevent-multiple-submit');
var i;
for (i = 0; i < preventButtons.length; i++) {
preventButtons[i].addEventListener('click', disableButton);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment