Ciao a tutti... ho lo script e il form, dei quali ho riportato il codice qua sotto, per fare il controllo dei campi obbligatori, solo che il controllo non viene eseguito. Qualche suggerimento e/o correzione da fare sul codice?
codice:<script language="javascript"> function controlla() { var ok = 1; if (form[0].nome.value == "") { alert("Il campo nome è obbligatorio!"); var ok = 0; } if (form[0].commento.value == "") { alert("Il commento è obbligatorio!"); var ok = 0; } if (form[0].mail.value == "") { alert("La mail è obbligatoria!"); var ok = 0; } if (ok == 1) { form[0].submit(); } } </script> <form action="index.php?action=insert" method="post" enctype="multipart/form-data" name="guestbook" onsubmit="return controlla()"> <table width="400" border="0" cellspacing="0" cellpadding="0" align="center"> <tr> <td width="40%">Nome/name*:</td> <td width="60%"><input type="text" name="nome" /></td> </tr> <tr> <td>Commento/comment*:</td> <td><textarea name="commento" cols="30" rows="10" id="commento"></textarea></td> </tr> <tr> <td>e-mail*:</td> <td><input name="mail" type="text" id="mail" /></td> </tr> <tr> <td>URL:</td> <td><input name="url" type="text" id="url" /></td> </tr> <tr> <td></td> <td></td> </tr> <tr> <td colspan="2"><div align="center">Il tuo indirizzo IP è/Your IP address is: <span style="color:#FF0000; background-color:#FF9900; font-weight:bold; font-size:14px;">158.110.43.204</span>. </div></td> </tr> <tr> <td colspan="2"><div align="center">Il tuo indirizzo IP è stato registrato./ Your IP address was registered. </div></td> </tr> <tr> <td></td> <td></td> </tr> <tr> <td colspan="2">* Questi campi sono obbligatori./These fileds are obligatories. </td> </tr> <tr> <td></td> <td></td> </tr> <tr> <td> <input type="hidden" value="23/5/2006 11:10:28" name="data" /> <input name="rem_ip" type="hidden" value="158.110.43.204" /></td> <td><input name="submit" type="submit" value="Invia/Submit" /> .:. <input name="reset" type="reset" id="reset" value="Reset" /></td> </tr> </table> </form>
ciao e grazie mille!!!!!!!!!!

Rispondi quotando