Jump to content

validating form


mvsveena

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...