javascript stop form submit if validation fails

Solutions on MaxInterview for javascript stop form submit if validation fails by the best coders in the world

showing results for - "javascript stop form submit if validation fails"
Sofia
29 Aug 2017
1<form onsubmit = "event.preventDefault(); myValidation();">
2
3<script>
4  function myValidation()
5{
6   if(check if your conditions are not satisfying)
7   {
8      alert("Oops! Validation failed!");
9      returnToPreviousPage();
10      return false;
11   }
12   alert("Validations successful!");
13   return true;
14}
15  </script>