Created
August 29, 2018 08:45
-
-
Save benny-sun/b2a5e009c5ea31e46e10e4977ab879b8 to your computer and use it in GitHub Desktop.
Prevent form double submission with vanilla js
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
var form = document.getElementById("form1") | |
form.addEventListener("submit", function (e) { | |
if (true === this.isSubmit) { | |
e.preventDefault() | |
} else { | |
this.isSubmit = true | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment