- Home
- Categorie
- Coding e Sistemistica
- HTML e CSS
- modulo contatti
-
modulo contatti
Ciao, utilizzo un modulo contatti di aruba (hosting windows) che ha come campo obblicatorio solo l'email, io vorrei rendere invece obbligatori tutti i campi ma non so come fare.
Il codice html del form è:
[html]<form action="amministrazione.asp" method="post" name="form1" id="form1" onsubmit="MM_validateForm('email','','RisEmail');return document.MM_returnValue">
<table width="395" border="0" align="center" cellpadding="1" cellspacing="1 ">
<tr>
<td width="124">Nome:</td>
<td width="219"><input name="Nome" type="text" class="campo" id="Nome" size="30" /> </td>
</tr>
<tr>
<td>Cognome:</td>
<td><input name="Cognome" type="text" class="campo" id="Cognome" size="30" /> </td>
</tr>
<tr>
<td>Indirizzo:</td>
<td><input name="Indirizzo" type="text" class="campo" id="Indirizzo" size="30" /> </td>
</tr>
<tr>
<td>C.A.P.:</td>
<td><input name="CAP" type="text" class="campo" id="CAP" size="10" /> </td>
</tr>
<tr>
<td>Comune:</td>
<td><input name="Comune" type="text" class="campo" id="Comune" size="30" /> </td>
</tr>
<tr>
<td>Provincia:</td>
<td><select name="Provincia" class="campo" id="select2">
<option selected="selected">- -</option>
<option>AG</option>
<option>AL</option>
<option>AN</option>
<option>AO</option>
<option>AQ</option>
<option>AR</option>
<option>AP</option>
<option>AT</option>
<option>AV</option>
<option>BA</option>
<option>BL</option>
<option>BN</option>
<option>BG</option>
<option>BI</option>
<option>BO</option>
<option>BZ</option>
<option>BS</option>
<option>BR</option>
<option>CA</option>
<option>CL</option>
<option>CB</option>
<option>CE</option>
<option>CT</option>
<option>CZ</option>
<option>CH</option>
<option>CO</option>
<option>CS</option>
<option>CR</option>
<option>CN</option>
<option>EN</option>
<option>FE</option>
<option>FI</option>
<option>FG</option>
<option>FC</option>
<option>FR</option>
<option>GE</option>
<option>GO</option>
<option>GR</option>
<option>IM</option>
<option>IS</option>
<option>KR</option>
<option>LT</option>
<option>LE</option>
<option>LC</option>
<option>LI</option>
<option>LO</option>
<option>LU</option>
<option>MC</option>
<option>MN</option>
<option>MS</option>
<option>MT</option>
<option>ME</option>
<option>MI</option>
<option>NA</option>
<option>NO</option>
<option>NU</option>
<option>OR</option>
<option>PD</option>
<option>PA</option>
<option>PR</option>
<option>PV</option>
<option>PG</option>
<option>PU</option>
<option>PE</option>
<option>PC</option>
<option>PI</option>
<option>PT</option>
<option>PN</option>
<option>PZ</option>
<option>PO</option>
<option>RG</option>
<option>RA</option>
<option>RC</option>
<option>RE</option>
<option>RI</option>
<option>RN</option>
<option>RM</option>
<option>RO</option>
<option>SA</option>
<option>SP</option>
<option>SS</option>
<option>SV</option>
<option>SI</option>
<option>SR</option>
<option>SO</option>
<option>TA</option>
<option>TE</option>
<option>TR</option>
<option>TO</option>
<option>TP</option>
<option>TN</option>
<option>TV</option>
<option>TS</option>
<option>UD</option>
<option>VA</option>
<option>VE</option>
<option>VB</option>
<option>VC</option>
<option>VR</option>
<option>VV</option>
<option>VI</option>
<option>VT</option>
</select> </td>
</tr>
<tr>
<td>Telefono:</td>
<td><input name="Tel" type="text" class="campo" id="Tel" size="30" /> </td>
</tr>
<tr>
<td>email:</td>
<td><input name="email" type="text" class="campo" size="30" /> </td>
</tr>
<tr>
<td>Testo messaggio:</td>
<td><textarea name="Info" cols="40" rows="4" class="campo" id="Info"></textarea> </td>
</tr>
</table>
<br/>
<div align="center">
<input name="Submit" type="submit" class="pulsante" value="Invia" />
<input name="Submit" type="reset" class="pulsante" value="Cancella" />
</div>
</form>
[/html]
Invece il codice javasript è:function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d)&&d.all) x=d.all; for (i=0;!x&&i<d.forms.length;i++) x=d.forms*; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers*.document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_validateForm() { //v4.0 var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments; for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args*); if (val) { nm=val.name; if ((val=val.value)!="") { if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@'); if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n'; } else if (test!='R') { num = parseFloat(val); if (isNaN(val)) errors+='- '+nm+' must contain a number.\n'; if (test.indexOf('inRange') != -1) { p=test.indexOf(':'); min=test.substring(8,p); max=test.substring(p+1); if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n'; } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; } } if (errors) alert('The following error(s) occurred:\n'+errors); document.MM_returnValue = (errors == ''); } ```Mi aiutereste per favore a fare le modifiche necessarie per rendere tutti i campi del modulo obbligatori? Grazie :ciauz: