Answers for "prevent form from reloading with preventDefault"

1

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!!!!!");
}
})
Posted by: Guest on September-06-2021

Code answers related to "prevent form from reloading with preventDefault"

Code answers related to "Javascript"

Browse Popular Code Answers by Language