Answers for "javascript stop form submit if validation fails"

0

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>
Posted by: Guest on June-12-2021

Browse Popular Code Answers by Language