javascript validate form without submit code example
Example 1: javascript prevent form submit
<form name="foo" onsubmit="return false">
Example 2: js form submit listener
document.getElementById("#myFormId").addEventListener("submit", function(e){
if(!isValid){
e.preventDefault(); //stop form from submitting
}
//do whatever an submit the form
});