document.getElementById("defaultsub").addEventListener("click", function(event){ if(document.querySelector('form').checkValidity()){ event.preventDefault(); console.log("Prevent default submission"); alert("ALERT!!!!!"); } })