Showing posts with label Form Submition. Show all posts
Showing posts with label Form Submition. Show all posts

Tuesday, October 8, 2013

How to use JavaScript form submition with other function validation

If validateForm(...) and validateForm1() return a boolean (true means that no validation error occurred), then you try to do that :


function returnTrue() {
            if(validateForm1() && validateForm2 && validateForm3()) {
  document.form1.submit();
                return true;
            } else {
                document.getElementById('validation').innerHTML = 'Validation failed!';
                return false;
            }
        }
<form action=""  method="post"  name="form1" enctype="multipart/form-data" onSubmit="return returnTrue()">
First name: 
<input type="text" name="FirstName" value="Mickey"><br>
Last name: 
<input type="text" name="LastName" value="Mouse"><br>
<input type="text" name="Submit" value="Submit">

</form>