Ciao a tutti,
avrei la necessità di fare un controllo dei campi obbligatori.
Questo è il codice che ho fatto
<HEAD>
function controllo(){
with(nomequestapaginaPHP.inviadati) {
if(textCognome.value=="") {
alert("Errore: compilare il campo COGNOME");
textCognome.focus();
return false;
}
if(textNome.value=="") {
alert("Errore: compilare il campo NOME");
textNome.focus();
return false;
}
if(textNumAVS.value=="") {
alert("Errore: compilare il campo NUMERO AVS");
textNumAVS.focus();
return false;
}
if(textComune.value=="") {
alert("Errore: selezionare il COMUNE");
textComune.focus();
return false;
}
}
alert("Controllo effettuato con successo. Il modulo sarà inviato.");
return true;
}
</SCRIPT>
</head>
<body>
<form name="dati" action= "nomediquestapaginaPHP.php" method = " GET ">
<table align ="center">
<tr><td>Cognome*</td>
<td><input id="textCognome" maxLength="50" name="Cognome"> <input id="Commento_Cognome" name="Commento_Cognome" type="submit" value="*"> </td>
<tr><td>Nome*</td>
<td><input id="textNome" maxLength="50" name="Nome"> <input id="Commento_Nome" name="Commento_Nome" type="submit" value="*"> </td>
<tr><td>N°AVS*</td>
<td><input id="textNumAVS" maxLength="50" name="NumAVS">
<input id="Commento_NumAVS" name="Commento_NumAVS" type="submit" value="*"> </td>
<td></td></tr>
<tr><td>Comune*</td>
<td><select id="textComune" name="Comune" size="1" maxLength="50">
<option selected><? echo($_GET["Comune"]);?> </option>
<option>comune1</option>
<option>comune2</option>
</select>
<input id="Commento_Comune" name="Commento_Comune" type="submit" value="*"> </td> </tr>
</form>
<tr><td></td>
<td>
<form name="inviadati" onSubmit="return controllo();" method = "post" action = "pagina2.php">
<input id="DatiPersonali" name="DatiPersonali" type="Submit" value="Invia dati personali">
</form>
qualcuno può aiutarmi? Thanks
![]()

Rispondi quotando
... ora cmq mi fa il controllo dei campi obbligatori... l'unica pecca è che non mi aggiunge + i commenti alla fine cliccando sugli appositi bottoni *
sto pome lo rivedo x benino va 