Ciao a tutti.
Ho fatto una pagina jsp dove c'è un form di registrazione.
Ho Utilizzato Javascript per fare il controllo dei vari campi.
Il problema è che lo script non funziona ; quando premo il bottone per confermare il form non succede niente , i campi non vengono verificati.
Mi aiutate ?
Vi posto il codice :
Graziecodice:<%-- Document : registrati Created on : 19-nov-2015, 11.54.40 Author : Giovanni --%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Pagina della Registrazione</title> <link href="http://127.0.0.1:8080/GMarkusStore-war/FogliStileCSS/Foglio1.css" rel="stylesheet" type="text/css"> <script language="Javascript"> <!-- function ControlloCampi() { var Nome = document.FormRegistrazione.Nome.value; var Cognome = document.FormRegistrazione.Cognome.value; var CodiceFiscale = document.FormRegistrazione.CodiceFiscale.value; //Espressione regolare del Codice Fiscale : var PatternCF = /^[a-zA-Z] {6} [0-9] {2} [a-zA-Z] [0-9] {2} [a-zA-Z] [0-9] {3} [a-zA-Z] $/; var Indirizzo = document.FormRegistrazione.Indirizzo.value; var CAP = document.FormRegistrazione.CAP.value; var Località = document.FormRegistrazione.Località.value; var Provincia = document.FormRegistrazione.Provincia.value; var Stato = document.FormRegistrazione.Stato.value; var Telefono = document.FormRegistrazione.Telefono.value; var Email = document.FormRegistrazione.Email.value; //Espressione regolare dell'Email : var patternEmail = /^([a-zA-Z0-9_\.\-])+@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/; var Username = document.FormRegistrazione.Username.value; var Password = document.FormRegistrazione.Password.value; var RipetiPassword = document.FormRegistrazione.RipetiPassword.value; if((Nome == "" || (!isNaN(Nome)))){ alert("Il campo Nome è Obbligatorio!"); document.FormRegistrazione.Nome.value = ""; document.FormRegistrazione.Nome.focus(); return false; } else if(Cognome == "" || (!isNaN(Cognome)))){ alert("Il campo Cognome è Obbligatorio!"); document.FormRegistrazione.Cognome.value = ""; document.FormRegistrazione.Nome.focus(); return false; } else if(CodiceFiscale.value > 16 || !patternCF.test(CodiceFiscale) || CodiceFiscale == ""){ alert("Inserire un Codice Fiscale Valido!") document.FormRegistrazione.Nome.focus(); return false; } else if(Indirizzo == ""){ alert("Il campo Indirizzo è Obbligatorio"); document.FormRegistrazione.Indirizzo.focus(); return false; } else if(CAP == ""||(isNaN(CAP))){ alert("Inserire un CAP Valido!"); document.FormRegistrazione.CAP.focus(); return false; } else if(Località == ""){ alert("Inserire una Località Valida!"); document.FormRegistrazione.Località.focus(); return false; } else if(Provincia.value > 2 || Provincia == "" || (!isNaN(Provincia))){ alert("Inserire una Provincia Valida!"); document.FormRegistrazione.Provincia.value = ""; document.FormRegistrazione.Provincia.focus(); return false; } else if(Stato == "" || (!isNaN(Stato))){ alert("Inserire uno Stato!"); document.FormRegistrazione.Stato.value = ""; document.FormRegistrazione.Stato.focus(); return false; } else if(Telefono == "" || (isNaN(Telefono))){ alert("Inserire un Numero di Telefono Valido!"); document.FormRegistrazione.Telefono.focus(); return false; } else if(Email == "" || !patternEmail.test(Email)){ alert("Inserire una Email Valida!"); document.FormRegistrazione.Email.focus(); return false; } else if(Username == ""){ alert("Inserire un Username!"); document.FormRegistrazione.Username.focus(); return false; } else if(Password == ""){ alert("Inserire una Password!"); document.FormRegistrazione.Password.focus(); return false; } else if(RipetiPassword == ""){ alert("Digita Nuovamente la Password che hai Scelto"); document.FormRegistrazione.RipetiPassword.focus(); return false; } else if(Password != RipetiPassword){ alert("La Password Confermata è Diversa da quella Scelta , Controllare!"); document.FormRegistrazione.RipetiPassword.value = ""; document.FormRegistrazione.RipetiPassword.focus(); return false; } else { alert("Dati OK"); } } --> </script> </head> <body background="http://127.0.0.1:8080/GMarkusStore-war/Immagini/img_background/sfondo-paginaWebSpazio.gif"> <%@ include file="../header.jsp" %> <br> <button class="bottoneNonCliccabile">Registrati</button> <br> <br> <table class="tabelle"> <form name="FormRegistrazione" method="post" action="registrazioneOK.jsp"> <tr> <td> <font class="testoBiancoFluorescente">Nome :</font> </td> <td> <input class="caselleInput" type="text" name="Nome"> </td> </tr> <tr> <td> <font class="testoBiancoFluorescente">Cognome :</font> </td> <td> <input class="caselleInput" type="text" name="Cognome"> </td> </tr> <tr> <td> <font class="testoBiancoFluorescente">Codice Fiscale :</font> </td> <td> <input class="caselleInput" type="text" name="CodiceFiscale"> </td> </tr> <tr> <td> <font class="testoBiancoFluorescente">Indirizzo :</font> </td> <td> <input class="caselleInput" type="text" name="Indirizzo"> </td> </tr> <tr> <td> <font class="testoBiancoFluorescente">CAP :</font> </td> <td> <input class="caselleInput" type="text" name="CAP"> </td> </tr> <tr> <td> <font class="testoBiancoFluorescente">Località :</font> </td> <td> <input class="caselleInput" type="text" name="Località"> </td> </tr> <tr> <td> <font class="testoBiancoFluorescente">Provincia :</font> </td> <td> <input class="caselleInput" type="text" name="Provincia"> </td> </tr> <tr> <td> <font class="testoBiancoFluorescente">Stato :</font> </td> <td> <input class="caselleInput" type="text" name="Stato"> </td> </tr> <tr> <td> <font class="testoBiancoFluorescente">Telefono :</font> </td> <td> <input class="caselleInput" type="text" name="Telefono"> </td> </tr> <tr> <td> <font class="testoBiancoFluorescente">Email :</font> </td> <td> <input class="caselleInput" type="text" name="Email"> </td> </tr> <tr> <td> <font class="testoBiancoFluorescente">Username :</font> </td> <td> <input class="caselleInput" type="text" name="Username"> </td> </tr> <tr> <td> <font class="testoBiancoFluorescente">Password :</font> </td> <td> <input class="caselleInput" type="password" name="Password"> </td> </tr> <tr> <td> <font class="testoBiancoFluorescente">Ripeti Password :</font> </td> <td> <input class="caselleInput" type="password" name="RipetiPassword"> </td> </tr> <tr></tr> <tr> <td></td> <td></td> <td> <input class="bottone" type="button" value="Registra" onclick="ControlloCampi()" > </td> </tr> <tr height="5"></tr> </form> </table> </body> </html>
Ciao

Rispondi quotando