Jump to content

validating form


mvsveena
 Share

Recommended Posts

Hi all,I am trying to validate my form in javascript and then passing the data's to php, to store it in the database. When I click on my submit button, the javascript validates and the data's are not passed to php. If I skip my javascript validation, it talks to php. formvalid.php

<?php	 session_start();	 if(isset($_POST['subbutton']))  	 {		 $user = register(); //calling the function register()	 ..........	 ..........		   <head>			<script src="http://localhost//formvalidV1.2.js" type="text/javascript"> </script> 	 ............	 .............		   <body>	 ..............	 ..............				  <form name="newuser_form" action="<?php $_SERVER['PHP_SELF']; ?>" method="post">		  <table align="left" cellspacing="20" cellpadding="5">				  <tr><td> 					 <label> First Name : </label> <input type="text" name="first_name" size=20 tabindex="1"> 				  </td></tr> 				  <tr><td> 					 <label> Last Name : </label> <input type="text" name="last_name" size=20 tabindex="2">  				  </td></tr>   	 ...............	 ...............				 <input type="button" name="subbutton" value="Submit" size="32" tabindex="11"  onClick="verifyData(this.form)">	 ...............	 ...............

If I change my input type="button" as input type="submit", it passes the data to php but not undergoing any form validation. If I use input type="button", it does the form validation, but not passing the data to php. Anyone can help me in achieving both the things together.Thanks in advance.

Link to comment
Share on other sites

The verifyData() method needs to return true. If it returns false, the form will not be submitted.If you don't know why the form is returning false, show it to us, so that we may figure that out.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...