function(event) {
event.preventDefault();
}
<form onsubmit="event.preventDefault(); return validateMyForm()">
for arrow function
const handleSubmit = (e)=>{
e.preventDefault()
}
document.querySelector("#id-checkbox").addEventListener("click", function(event) {
document.getElementById("output-box").innerHTML += "Sorry! <code>preventDefault()</code> won't let you check this!<br>";
event.preventDefault();
}, false);
$('#test').on("keypress",function (evt) {
if (this.value.length == 1 && evt.which == 48 )
{
evt.preventDefault();
}
});
< form action = javascript: void(0);>
****************OR********************
$("#yourFormId").on("submit",function(event){event.preventDefault()})