Created
June 19, 2024 12:18
-
-
Save Langmans/edf0bde71595bcf9cbb8165f653e6fe9 to your computer and use it in GitHub Desktop.
disable submit buttons on page leave
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
// this disables users clicking the submit button multiple times for forms without submit event handlers. | |
window.onbeforeunload = function () { | |
Array.from(document.querySelectorAll('[type=submit],[type=image],[type=reset]')).forEach(function (el) { | |
if (el.form) { | |
el.disabled = true; | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment