Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

prevent form from reloading with preventDefault

document.getElementById("defaultsub").addEventListener("click", function(event){
    if(document.querySelector('form').checkValidity()){
     event.preventDefault();
     console.log("Prevent default submission");
     alert("ALERT!!!!!");
}
})
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #prevent #form #reloading #preventDefault
ADD COMMENT
Topic
Name
6+5 =