I have a simple html form and Javascript. I have been trying to prevent form submission. but it ignores my code e.preventDefault()
and continues to submit and refreshes the page anyways.
most solutions I encountered include JQuery. can't this be done without JQuery?
why is this not working? what is the problem?
<html>
<head>
<script>
function onsubmit(e) {
e.preventDefault();
e.stopPropagation();
console.log("submitting...");
return false;
}
</script>
</head>
<body>
<form method="POST" onsubmit="onsubmit">
<input placeholder="email" style="display:block"> </input>
<input placeholder="password" style="display:block"> </input>
<input type="submit" value="login" style="display:block"> </input>
</form>
</body>
</html>