Visualizzazione dei risultati da 1 a 10 su 11

Hybrid View

  1. #1
    Utente di HTML.it
    Registrato dal
    Feb 2011
    Messaggi
    339

    Problema controllo campi form con javascript

    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 :

    codice:
    <%-- 
        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>
    Grazie
    Ciao

  2. #2
    Utente di HTML.it L'avatar di vic53
    Registrato dal
    Oct 2010
    residenza
    Fonte Nuova (Roma)
    Messaggi
    592
    Quote Originariamente inviata da Markus85 Visualizza il messaggio
    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 :

    codice:
    <%-- 
        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>
    Grazie
    Ciao

    ciao
    conta le parentesi aperte e chiuse ... devono pareggiare

    esempio questa riga
    if((Nome == "" || (!isNaN(Nome)))){
    dovrebbe essere così
    if((Nome == "") || (!isNaN(Nome)){
    ciao ricontrolla le istr.
    Vic53

  3. #3
    Utente di HTML.it L'avatar di vic53
    Registrato dal
    Oct 2010
    residenza
    Fonte Nuova (Roma)
    Messaggi
    592
    Quote Originariamente inviata da vic53 Visualizza il messaggio
    ciao
    conta le parentesi aperte e chiuse ... devono pareggiare

    esempio questa riga

    dovrebbe essere così


    ciao ricontrolla le istr.
    scusa la distrazione
    la riga è così..
    if((Nome == "") || ((!isNaN(Nome))){
    ...
    ciao
    Vic53

  4. #4
    Utente di HTML.it
    Registrato dal
    Feb 2011
    Messaggi
    339
    Ho sistemato le parentesi...
    Ancora niente.

    codice:
    <%@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 type="text/javascript">
         
            function ControlloCampi() {
                
                //var form = document.forms['FormRegistrazione'];
                //var array = new array();
                //for(var i = 0;  i < form.length; i++){
                    //array[document.forms[i].name] = document.forms[i].value;
                }
                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)) ||(Nome == "undefined")){
                    window.alert("Il campo Nome è Obbligatorio!");
                    document.FormRegistrazione.Nome.value = "";
                    document.FormRegistrazione.Nome.focus();
                    return false;
                    
                }
                
                else if((Cognome == "") || (!isNaN(Cognome)) || (Cognome == "undefined")){
                    alert("Il campo Cognome è Obbligatorio!");
                    document.FormRegistrazione.Cognome.value = "";
                    document.FormRegistrazione.Nome.focus();
                    return false;
                }
                
                else if((CodiceFiscale.value > 16) || (!patternCF.test(CodiceFiscale)) || (CodiceFiscale == "") || (CodiceFiscale == "undefined")){
                    alert("Inserire un Codice Fiscale Valido!")
                    document.FormRegistrazione.Nome.focus();
                    return false;
                }
                
                else if((Indirizzo == "") || (Indirizzo == "undefined")){
                    alert("Il campo Indirizzo è Obbligatorio");
                    document.FormRegistrazione.Indirizzo.focus();
                    return false;
                }
                
                else if((CAP == "")||(isNaN(CAP)) || (CAP == "undefined")){
                    alert("Inserire un CAP Valido!");
                    document.FormRegistrazione.CAP.focus();
                    return false;
                }
                
                else if((Località == "") || (Località == "undefined")){
                    alert("Inserire una Località Valida!");
                    document.FormRegistrazione.Località.focus();
                    return false;
                }
                
                else if((Provincia.value > 2) || (Provincia == "") || (!isNaN(Provincia)) || (Provincia == "undefined")){
                    alert("Inserire una Provincia Valida!");
                    document.FormRegistrazione.Provincia.value = "";
                    document.FormRegistrazione.Provincia.focus();
                    return false;
                }
                
                else if((Stato == "") || (!isNaN(Stato)) || (Stato == "undefined")){
                    alert("Inserire uno Stato!");
                    document.FormRegistrazione.Stato.value = "";
                    document.FormRegistrazione.Stato.focus();
                    return false;
                }
                
                else if((Telefono == "") || (isNaN(Telefono)) || (Telefono == "undefined")){
                    alert("Inserire un Numero di Telefono Valido!");
                    document.FormRegistrazione.Telefono.focus();
                    return false;
                }
                else if((Email == "") || (!patternEmail.test(Email)) || (Email == "undefined")){
                    alert("Inserire una Email Valida!");
                    document.FormRegistrazione.Email.focus();
                    return false;
                }
                
                else if((Username == "") || (Username == "undefined")){
                    alert("Inserire un Username!");
                    document.FormRegistrazione.Username.focus();
                    return false;
                }
                
                else if((Password == "") || (Password == "undefined")){
                    alert("Inserire una Password!");
                    document.FormRegistrazione.Password.focus();
                    return false;
                }
                
                else if((RipetiPassword == "") || (RipetiPassword == "undefined")){
                    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" id="FormRegistrazione" method="post">                     
                               <tr>
                                   <td>
                            <font class="testoBiancoFluorescente">Nome :</font>
                                   </td>
                                   <td>
                            <input class="caselleInput" type="text" name="Nome" id="Nome">
                                   </td>
                               </tr>
                         
                            <tr>
                                   <td>
                            <font class="testoBiancoFluorescente">Cognome :</font>
                                   </td>
                                    <td>
                            <input class="caselleInput" type="text" name="Cognome" id="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>

  5. #5
    Utente di HTML.it L'avatar di vic53
    Registrato dal
    Oct 2010
    residenza
    Fonte Nuova (Roma)
    Messaggi
    592
    function ControlloCampi() {

    //var form = document.forms['FormRegistrazione'];
    //var array = new array();
    //for(var i = 0; i < form.length; i++){
    //array[document.forms[i].name] = document.forms[i].value;

    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 Localita = document.FormRegistrazione.Localita.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)) ||(Nome == "undefined")){
    alert("Il campo Nome è Obbligatorio!");
    document.FormRegistrazione.Nome.value = "";
    document.FormRegistrazione.Nome.focus();
    return false;

    }

    else if ((Cognome == "") || (!isNaN(Cognome)) || (Cognome == "undefined")){
    alert("Il campo Cognome è Obbligatorio!");
    document.FormRegistrazione.Cognome.value = "";
    document.FormRegistrazione.Nome.focus();
    return false;
    }

    else if ((CodiceFiscale.value > 16) || (!patternCF.test(CodiceFiscale)) || (CodiceFiscale == "") || (CodiceFiscale == "undefined")){
    alert("Inserire un Codice Fiscale Valido!")
    document.FormRegistrazione.Nome.focus();
    return false;
    }

    else if ((Indirizzo == "") || (Indirizzo == "undefined")){
    alert("Il campo Indirizzo è Obbligatorio");
    document.FormRegistrazione.Indirizzo.focus();
    return false;
    }

    else if ((CAP == "")||(isNaN(CAP)) || (CAP == "undefined")){
    alert("Inserire un CAP Valido!");
    document.FormRegistrazione.CAP.focus();
    return false;
    }

    else if ((Localita == "") || (Localita == "undefined")){
    alert("Inserire una Località Valida!");
    document.FormRegistrazione.Localita.focus();
    return false;
    }

    else if ((Provincia.value > 2) || (Provincia == "") || (!isNaN(Provincia)) || (Provincia == "undefined")){
    alert("Inserire una Provincia Valida!");
    document.FormRegistrazione.Provincia.value = "";
    document.FormRegistrazione.Provincia.focus();
    return false;
    }

    else if ((Stato == "") || (!isNaN(Stato)) || (Stato == "undefined")){
    alert("Inserire uno Stato!");
    document.FormRegistrazione.Stato.value = "";
    document.FormRegistrazione.Stato.focus();
    return false;
    }

    else if ((Telefono == "") || (isNaN(Telefono)) || (Telefono == "undefined")){
    alert("Inserire un Numero di Telefono Valido!");
    document.FormRegistrazione.Telefono.focus();
    return false;
    }
    else if ((Email == "") || (!patternEmail.test(Email)) || (Email == "undefined")){
    alert("Inserire una Email Valida!");
    document.FormRegistrazione.Email.focus();
    return false;
    }

    else if ((Username == "") || (Username == "undefined")){
    alert("Inserire un Username!");
    document.FormRegistrazione.Username.focus();
    return false;
    }

    else if ((Password == "") || (Password == "undefined")){
    alert("Inserire una Password!");
    document.FormRegistrazione.Password.focus();
    return false;
    }

    else if ((RipetiPassword == "") || (RipetiPassword == "undefined")){
    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>
    QUESTA è LA FUNZIONE CON ALCUNE CORREZIONI
    poi togli la à accentata da Località...
    te l'ho tolta dalla funzione, (in programmazione non si usano i car.accentati)

    naturalmente questa funzione l'hai scritta tu....
    (non voglio dire niente sul modo di scrivere le function perchè non mi piace fare il bacchettone)...



    ciao e buon lavoro..
    Ultima modifica di vic53; 14-12-2015 a 23:35
    Vic53

  6. #6
    Utente di HTML.it
    Registrato dal
    Feb 2011
    Messaggi
    339
    Ciao.
    Ho copiato il codice con le correzioni ma.....NISBA!
    Probabilmente credo che non riesco a far vedere allo script i valori dei campi di input del form.

    Ti scrivo una parte di codice per farti vedere come assegno le variabili :

    Prendiamo in considerazione la var "Nome" , ecco come la assegno nello script :

    codice:
    var Nome = document.FormRegistrazione.Nome.value;
    Questo è il tag form a cui ho assegnato il nome "FormRegistrazione :

    codice:
    <form name="FormRegistrazione" method="post">
    Il campo di input relativo al nome :

    codice:
    <input class="caselleInput" type="text" name="Nome">
    Infine il bottone del form che al click dovrebbe eseguire il metodo nello script :

    codice:
    <input class="bottone" type="button" value="Registra" onClick="ControlloCampi()">
    vedi qualche errore ?

    Tranquillo non sei "Bacchettone"

  7. #7
    Utente di HTML.it L'avatar di vic53
    Registrato dal
    Oct 2010
    residenza
    Fonte Nuova (Roma)
    Messaggi
    592
    non riesco a spedire il testo in risposta con le correzioni perchè è troppo lungo
    ora CI RIPROVO...
    Vic53

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.