Skip to content

Instantly share code, notes, and snippets.

@benny-sun
Created August 29, 2018 08:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benny-sun/b2a5e009c5ea31e46e10e4977ab879b8 to your computer and use it in GitHub Desktop.
Save benny-sun/b2a5e009c5ea31e46e10e4977ab879b8 to your computer and use it in GitHub Desktop.
Prevent form double submission with vanilla js
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