Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    [Js] controllo prima del submit

    Ciao ho questo controllo prima del submit ma non funziona chi mi sa aiutare??

    codice:
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <html>
    <head>
    <title>Untitled Document</title>
    <link href="../css/layout.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" language="javascript">
    <!--
    
            function checkForm (theForm)
            {
                    if (!theForm) return;
    
                    var noError = true;
                    var errorTxt = "";
    
                    if (document.forms[theForm].elements["Sped"].value == "") {
                            noError = false;
                            errorTxt += " - il campo 'nome' risulta vuoto\n";
                    }
    
                    if (document.theForm.elements["Nome"].value == "") {
                            noError = false;
                            errorTxt += " - il campo 'cognome' risulta vuoto\n";
                    }
    
                    if (document.forms[theForm].elements["Indirizzo"].value == "") {
                            noError = false;
                            errorTxt += " - il campo 'username pop3' risulta vuoto\n";
                    }
    
                    if (document.forms[theForm].elements["password_pop3"].value == "") {
                            noError = false;
                            errorTxt += " - il campo 'password pop3' risulta vuoto\n";
                    }
    
                    if (document.forms[theForm].elements["username_sms"].value == "") {
                            noError = false;
                            errorTxt += " - il campo 'username sms' risulta vuoto\n";
                    }
    
                    if (document.forms[theForm].elements["password_sms"].value == "") {
                            noError = false;
                            errorTxt += " - il campo 'password sms' risulta vuoto\n";
                    }
    
                    if ( isNaN(document.forms[theForm].elements["tot_sms"].value) ) {
                            noError = false;
                            errorTxt += " - il campo 'numero totali' risulta vuoto o non valido\n";
                    }
    
                    if (!noError) alert ("Si sono verificati i seguenti errori:\n" + errorTxt);
                    return noError;
            }
    
    //-->
    </script>
    </head>
    
    <body>
    <table width="500" border="0" cellspacing="0" cellpadding="0">
      <tr> 
        <td colspan="6" align="center" valign="middle" class="styleCopy">AGENDA - 
          INSERIMENTO NUOVO CLIENTE</td>
      </tr>
      <tr> 
        <td colspan="6" align="center" valign="middle">
    </td>
      </tr>
      <tr> 
        <td colspan="6" align="center" valign="middle">
    	<FORM action="Aggiungi_cli.asp" onsubmit="return checkForm(Info);" method="post" name="Info">
    		<table align="center" cellpadding="3" cellspacing="2" border="0" width="350">
              <tr>
    			<td align="right">Numero Spedizioniere:</td>
    			<td></td>
    			<td><input type="text" name="Sped"></td>
    			</tr>
    			<tr>
    			<td align="right">Nome completo:</td>
    			<td></td>
    			<td><input type="text" name="Nome"></td>
    			</tr>
    			<tr>
    			<td align="right">Indirizzo :</td>
    			<td></td>
    			<td><input type="text" name="Indirizzo"></td>
    			</tr>
    			<tr>
    			<td align="right">Nazione :</td>
    			<td></td>
    			<td><input type="text" name="Nazione"></td>
    			</tr>
    			<tr>
    			<td align="right">NAP :</td>
    			<td></td>
    			<td><input type="text" name="Nap"></td>
    			</tr>
    			<tr>
    			<td align="right">Citta' :</td>
    			<td></td>
    			<td><input type="text" name="Citta"></td>
    			</tr>
    			<tr>
    			<td align="right">Conto IVA :</td>
    			<td></td>
    			<td><input type="text" name="Iva"></td>
    			</tr>
    			<tr>
    			<td align="right">Conto Tributi :</td>
    			<td></td>
    			<td><input type="text" name="tributi"></td>
    			</tr>
    			<tr>
    			<td align="right">Numero IVA :</td>
    			<td></td>
    			<td><input type="text" name="ivanum"></td>
    			</tr>
    			<tr>
    			<td align="right">Licenza :</td>
    			<td></td>
    			<td><input type="text" name="Licenza"></td>
    			</tr>
    			<tr>
    			<td align="right">Versione :</td>
    			<td></td>
    			<td><select name="Versione" size="1">
                    <option>Scegli la versione</option>
                    <option value="1">V 1.0</option>
                    <option value="2">V 2.0</option>
                    <option value="3">V 2.0.+</option>
                  </select></td>
    			</tr>
    			<tr>
    			<td align="right">Lingua :</td>
    			<td></td>
    			<td><select name="Lingua"  size="1" id="Lingua">
                    <option>Scegli la lingua</option>
                    <option value="0">Italiano</option>
                    <option value="1">Tedesco</option>
                    <option value="2">Francese</option>
                  </select></td>
    			</tr>
    			<tr>
    			<td align="right">Tipo :</td>
    			<td></td>
    			<td><select name="Tipo"  size="1" id="Tipo">
                    <option>Scegli i programmi</option>
                    <option value="10000">M90 Import</option>
                    <option value="01000">M90 Export</option>
                    <option value="11000">M90 Import / Export</option>
                  </select></td>
    			</tr>
    
    			<tr><td align="center" colspan="3">
    
    </p>
                  
    
    
                    <input type="submit" class="style" value="Registra">
                  </p></td></tr>
    		</table>
    	</FORM>
    	</td>
      </tr>
    </table>
    </body>
    </html>

  2. #2
    Reale_Augello
    Guest

    Ecco...

    ... qui il codice corretto:

    codice:
    <script type="text/javascript" language="javascript">
    <!--
    
            function checkForm (theForm)
            {
                    if (!theForm) return;
    
                    var noError = true;
                    var errorTxt = "";
    
                    if (document.forms[theForm].elements["Sped"].value == "") {
                            noError = false;
                            errorTxt += " - il campo 'nome' risulta vuoto\n";
                    }
    
                    if (document.forms[theForm].elements["Nome"].value == "") {
                            noError = false;
                            errorTxt += " - il campo 'cognome' risulta vuoto\n";
                    }
    
                    if (document.forms[theForm].elements["Indirizzo"].value == "") {
                            noError = false;
                            errorTxt += " - il campo 'username pop3' risulta vuoto\n";
                    }
    
                    if (document.forms[theForm].elements["password_pop3"].value == "") {
                            noError = false;
                            errorTxt += " - il campo 'password pop3' risulta vuoto\n";
                    }
    
                    if (document.forms[theForm].elements["username_sms"].value == "") {
                            noError = false;
                            errorTxt += " - il campo 'username sms' risulta vuoto\n";
                    }
    
                    if (document.forms[theForm].elements["password_sms"].value == "") {
                            noError = false;
                            errorTxt += " - il campo 'password sms' risulta vuoto\n";
                    }
    
                    if ( isNaN(document.forms[theForm].elements["tot_sms"].value) ) {
                            noError = false;
                            errorTxt += " - il campo 'numero totali' risulta vuoto o non valido\n";
                    }
    
                    if (!noError) alert ("Si sono verificati i seguenti errori:\n" + errorTxt);
                    return noError;
    }
    
    //-->
    </script>
    Il richiamo della funzione è:

    <FORM action="Aggiungi_cli.asp" onsubmit="return checkForm('Info');" method="post" name="Info">

    In questa riga

    document.forms[theForm].elements["password_pop3"].value == ""

    fai riferimento al campo "password_pop3", che non esiste.

    Fammi sapere se ci sono altri problemi !

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 © 2024 vBulletin Solutions, Inc. All rights reserved.