Ciao,
dopo tanto tempo ho pensato di riprendere a costruire semplici pagine web, ma ho dimenticato un po' tutto quindi all'inizio provo a modificare dei file che trovo in rete.
Non riesco a capire il codice javascript non mi valida il contenuto del form (che di proposito inserisco errati) e passa subito ad inviare i dati allo script PHP addcustomer.php.
Questo il codice del file validatesignup.php con il modulo per la registrazione:
codice HTML:<html> <head> <script language="JavaScript" type="text/JavaScript" src="checkform.js"></script> </head> <body> <form action="addcustomer.php" method="post" onsubmit="return validate(this);"> <table border="0" cellspacing="1" cellpadding="3"> <tr><td colspan="2" align="center">Enter your information</td></tr> <tr><td>Email Address: </td><td> <input size="20" type="text" name="emailaddress" > <span id="emailmsg"></span></td></tr> <tr><td>Password: </td><td> <input size="20" type="password" name="password" ><span id="passwdmsg"></span></td></tr> <tr><td>ReType Password: </td><td> <input size="20" type="password" name="repassword"><span id="repasswdmsg"></span></td></tr> <tr><td>Complete Name </td><td> <input size="50" type="text" name="complete_name" ><span id="usrmsg"></span></td></tr> <tr><td>Address: </td><td> <input size="80" type="text" name="address1"></td></tr> <tr><td></td><td> <input size="80" type="text" name="address2"></td></tr> <tr><td>City: </td><td> <input size="30" type="text" name="city"></td></tr> <tr><td>State: </td><td> <input size="30" type="text" name="state"></td></tr> <tr><td>Country: </td><td> <input size="30" type="text" name="country"></td></tr> <tr><td>Zip Code: </td><td> <input size="20" type="text" name="zipcode"></td></tr> <tr><td>Phone No: </td><td> <input size="30" type="text" name="phone_no"></td></tr> <tr><td><input type="submit" name="submit" value="Submit"> </td><td> <input type="reset" value="Cancel"></td></tr> </table> </form> </body> </html> questo il file javascript richiamato per il controllo: [CODE] function validate(userForm) { div=document.getElementById("emailmsg"); div.style.color="red"; if(div.hasChildNodes()) { div.removeChild(div.firstChild); } regex=/(^\w+\@\w+\.\w+)/; match=regex.exec(userForm.emailaddress.value); if(!match) { div.appendChild(document.createTextNode("Invalid Email")); userForm.emailaddress.focus(); return false; } div=document.getElementById("passwdmsg"); div.style.color="red"; if(div.hasChildNodes()) { div.removeChild(div.firstChild); } if(userForm.password.value.length <=5) { div.appendChild(document.createTextNode("The password should be of at least size 6")); userForm.password.focus(); return false; } div=document.getElementById("repasswdmsg"); div.style.color="red"; if(div.hasChildNodes()) { div.removeChild(div.firstChild); } if(userForm.password.value != userForm.repassword.value) { div.appendChild(document.createTextNode("The two passwords don't match")); userForm.password.focus(); return false; } var div=document.getElementById("usrmsg"); div.style.color="red"; if(div.hasChildNodes()) { div.removeChild(div.firstChild); } if(userForm.complete_name.value.length ==0) { div.appendChild(document.createTextNode("Name cannot be blank")); userForm.complete_name.focus(); return false; } return true; } In pratica è come il codice JS non esistese. Potete aiutarmi a capiure cosa non va? Grazie [/CODE]

 
			
			 
					
					
					
						 Rispondi quotando
  Rispondi quotando 
			
