javascript stop form submit if validation failsed code example
Example: javascript stop form submit if validation fails
<form onsubmit = "event.preventDefault(); myValidation();">
<script>
function myValidation()
{
if(check if your conditions are not satisfying)
{
alert("Oops! Validation failed!");
returnToPreviousPage();
return false;
}
alert("Validations successful!");
return true;
}
</script>