Salve ragazzi ho un problema sun Jscrpit che mi controlla la validità dei campi di un form, in pratica la sintassi non viene eseguita e ricevo il seguente errore:
Sapete dirmi dove sbaglio...ci sbatto la testa da diverso tempo e non sono riuscito a risolvere il problema, ecco il codice:codice:Riga: 12 Carattere: 1 Errore: 'document.forum1.element.nome' è nullo o non è un oggetto
codice:<html> <head> <title></title> <SCRIPT language=JavaScript> function hilite(field) { if (document.all) { document.form1.elements[field].style.backgroundColor='#FFFFCC'; } } function testData() { if (document.form1.elements['nome'].value == '') { alert ('\nCampo Nome e Cognome o Ragione Sociale obbligatorio!\t\n') hilite ('nome'); document.form1.elements['nome'].focus(); return false; } if (document.form1.elements['prov'].value == '') { alert ('\nCampo Provincia obbligatorio!\t\n') hilite ('prov'); document.form1.elements['prov'].focus(); return false; } if (document.form1.elements['sede'].value == '') { alert ('\nCampo Indirizzo obbligatorio!\t\n') hilite ('sede'); document.form1.elements['sede'].focus(); return false; } if (document.form1.elements['cap'].value == '') { alert ('\nCampo C.A.P. obbligatorio!\t\n') hilite ('cap'); document.form1.elements['cap'].focus(); return false; } if (document.form1.elements['citi'].value == '') { alert ('\nCampo Città obbligatorio!\t\n') hilite ('citi'); document.form1.elements['citi'].focus(); return false; } if (document.form1.elements['telefono'].value == '') { alert ('\nCampo Telefono obbligatorio!\t\n') hilite ('telefono'); document.form1.elements['telefono'].focus(); return false; } if (document.form1.elements['nation'].value == '') { alert ('\nCampo Nazione obbligatorio!\t\n') hilite ('nation'); document.form1.elements['nation'].focus(); return false; } if (document.form1.elements['cod'].value == '') { alert ('\nCampo Codice Fiscale o Partita IVA obbligatorio!\t\n') hilite ('cod'); document.form1.elements['cod'].focus(); return false; } if (document.form1.elements['email'].value == '') { alert ('\nCampo Email obbligatorio!\t\n') hilite ('email'); document.form1.elements['email'].focus(); return false; } if ((document.form1.elements['email'].value.indexOf('@')<1)||(document.form1.elements['email'].value.indexOf('.')<1)){ alert('E-mail non valida') hilite ('email'); document.form1.elements['email'].focus(); return false; } if (GetRadioValue('privaci') != 'accetto'){ alert ('E necessario dare il consenso sulla Pricacy'); return false; } if (GetRadioValue('condizioni') != 'accetto'){ alert ('E neccessario dare il consenso sulle Condizioni'); return false; } return true; } </SCRIPT> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="../images/style.css" rel="stylesheet" type="text/css"> <SCRIPT> <!-- function piccola(str) { searchWin = window.open(str,'piccola','scrollbars=no,resizable=yes,width=450, height=130, status=no,location=no,toolbar=no'); // searchWin.refer = self; } function testAll() { if (!testData()){ return false; } if (GetRadioValue('privaci') != 'accetto'){ alert ('E necessario dare il consenso sulla Pricacy'); return false; } if (GetRadioValue('condizioni') != 'accetto'){ alert ('E neccessario dare il consenso sulle Condizioni'); return false; } } function GetRadioValue(radioName) { var collection; collection = document.form1.elements[radioName]; for (i=0;i<collection.length;i++) if (collection[i].checked == true) return collection[i].value; return ''; } function MM_openBrWindow(theURL,winName,features) { //v2.0 window.open(theURL,winName,features); } //--> </SCRIPT> </HEAD> <body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> <FORM name=form1 action=mail.asp method=post> <table width="400" border="0" align="center" cellpadding="0" cellspacing="0"> <tr align="center" class="verdana11grigio"> <td width="113" height="35" valign="middle"> Ragione Sociale Cognome/Nome </td> <td height="35" valign="middle"> </td> <td height="35" valign="middle"> <input name="nome" type="text" class="box" id="nome2" size="55"> </td> </tr> <tr align="center" class="verdana11grigio"> <td width="113" height="25" valign="middle"> Provincia</td> <td width="10" height="25" valign="middle"> </td> <td width="277" height="25" valign="middle"> <input name="prov" type="text" class="box" id="fax3" size="30"> </td> </tr> <tr align="center" class="verdana11grigio"> <td height="25" valign="middle"> Indirizzo</td> <td height="25" valign="middle"></td> <td height="25" valign="middle"> <input name="sede" type="text" class="box" id="sede" size="55"> </td> </tr> <tr align="center" class="verdana11grigio"> <td height="25"> C.A.P.</td> <td height="25" valign="middle"></td> <td height="25" valign="middle"> <input name="cap" type="text" class="box" id="cap" size="20"> </td> </tr> <tr align="center" class="verdana11grigio"> <td height="25" valign="middle"> Città</td> <td height="25" valign="middle"></td> <td height="25" valign="middle"> <input name="citi" type="text" class="box" id="citi" size="55"> </td> </tr> <tr class="verdana11grigio"> <td height="25"> Telefono</td> <td height="25" rowspan="3"></td> <td height="25"> <input name="telefono" type="text" class="box" id="telefono" size="30"> </td> </tr> <tr class="verdana11grigio"> <td height="25"> Fax</td> <td height="25"> <input name="fax" type="text" class="box" id="fax" size="30"> </td> </tr> <tr class="verdana11grigio"> <td height="25">Nazione</td> <td height="25"> <input name="nation" type="text" class="box" id="nation" size="30"> </td> </tr> <tr class="verdana11grigio"> <td height="25"> Indirizzo e.mail</td> <td height="25"></td> <td height="25"> <input name="email" type="text" class="box" id="email" size="55"> </td> </tr> <tr class="verdana11grigio"> <td height="40" colspan="3"> <table width="10" height="10" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="8"></td> </tr> </table> <TEXTAREA name=informativa rows=5 wrap=VIRTUAL class="box02" cols=60></TEXTAREA> <table width="10" height="5" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="8"></td> </tr> </table> Accetto <INPUT type=radio value=accetto name=privaci> Non Accetto <INPUT type=radio value=nonaccetto name=privaci> </td> </tr> <tr> <td height="40" colspan="3"> <table width="10" height="10" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="8"></td> </tr> </table> <TEXTAREA name=textarea rows=5 wrap=VIRTUAL class="box02" cols=60></TEXTAREA> <table width="10" height="5" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="8"></td> </tr> </table> Accetto <INPUT type=radio value=accetto name=condizioni> Non Accetto <INPUT type=radio value=nonaccetto name=condizioni> </td> </tr> <tr> <td height="20" colspan="3"></td> </tr> <tr> <td colspan="3"> <INPUT onclick="javascript: return testAll();" type=submit value="Accetto e proseguo con l'iscrizione" name=Submit2> <INPUT type=hidden value=Gratis name=TipoIscrizione> </td> </tr> </table> </form> </body>

Rispondi quotando
