Il mio problema è il segente:
devo creare un modulo per l'invio delle mail, ho usato il form e tuttigli input, tuttavia ci sono dei dati obbligatori e quindi un controllo tuttavia il codice non funziona...
il pulsante, di base disabilitato, dopo i vari controlli dovrebbe ativarsi ma non fa niente... come posso fare?
ecco il codice della pagina:
codice:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Segnalazione</title>
<script type="text/javascript">
function numbersonly(myfield, e, dec) {
var key;
var keychar;
if (window.event)
key = window.event.keyCode;
else if (e)
key = e.which;
else
return true;
keychar = String.fromCharCode(key);
// control keys
if ((key==null) || (key==0) || (key==8) || (key==9) || (key==13) || (key==27) )
return true;
// numbers
else if ((("0123456789").indexOf(keychar) > -1))
return true;
// decimal point jump
else if (dec && (keychar == ".")) {
myfield.form.elements[dec].focus();
return false;
} else
return false;
}
function ControllaMail()
{
EmailAddr = document.getElementsById("ID_email").value;
Filtro = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
if (Filtro.test(EmailAddr))
return true;
else
{
return false;
}
}
function controlla()
{
clearTimeout();
if (document.getElementsById("ID_Società").value!="")
{
if (document.getElementsById("ID_Attività").value!="")
if (document.getElementsById("ID_Nome").value!="")
if (document.getElementsById("ID_Cognome").value!="")
if (document.getElementsById("ID_Telefono").value!="")
if (document.getElementsById("ID_MSG").value!="")
if (ControllaMail())
if (document.getElementById("Controllo").checked)
document.getElementById("Invio").disabled=false;
}
else
document.getElementById("Invio").disabled=true;
setTimeout("controlla()",10)
}
</script>
</head>
<body style="font-family:'Century Gothic'" onload="controlla()">
<form method="get" action="mail.php">
<table border="0">
<tr>
<td>Società<span style="color:#F00">*</span>:</td><td><input type="text" name="Società" id="ID_Società" size="50"></td>
</tr>
<tr>
<td>Attività<span style="color:#F00">*</span>:</td><td><input type="text" name="Attività" id="ID_Attività" size="50"></td>
</tr>
<tr>
<td>Nome<span style="color:#F00">*</span>:</td><td><input type="text" name="Nome" id="ID_Nome"size="25"></td>
</tr>
<tr>
<td>Cognome<span style="color:#F00">*</span>:</td><td><input type="text" name="Cognome" id="ID_Cognome" size="25"></td>
</tr>
<tr>
<td>Indirizzo:</td><td><input type="text" name="Indirizzo" id="ID_Indirizzo" size="50"></td>
</tr>
<tr>
<td>Città:</td><td><input type="text" name="Città" id="ID_Città" size="50"></td>
</tr>
<tr>
<td>Provincia:</td><td><input type="text" name="Provincia" id="ID_Provincia" maxlength="2" size="5"></td>
</tr>
<tr>
<td>Cap:</td><td><input type="text" name="CAP" id="ID_CAP" maxlength="5" size="10" onkeypress="return numbersonly(this, event)"></td>
</tr>
<tr>
<td>Telefono<span style="color:#F00">*</span>:</td><td><input type="text" name="Telefono" id="ID_Telefono" size="50" onkeypress="return numbersonly(this, event)"></td>
</tr>
<tr>
<td>Fax:</td><td><input type="text" name="Fax" id="ID_Fax" size="50" onkeypress="return numbersonly(this, event)"></td>
</tr>
<tr>
<td>Messaggio <span style="color:#F00">*</span>:</td><td><textarea name="Msg" id="ID_MSG" cols="80" rows="10"></textarea></td>
</tr>
<tr>
<td>Tua Email <span style="color:#F00">*</span>:</td><td><input type="text" name="email" id="ID_email" size="50"></td>
</tr>
<tr>
<td colspan="2" align="center">
<b style="color:#F00;">Informativa ai sensi della legge 196/2003[/b]
<span style="text-align:justify">I dati personali che lei vorrà liberamente comunicarci, compilando questo modulo, verranno registrati su supporti elettronici protetti e trattati in modo riservato.</span>
<input type="checkbox" id="Controllo"/> Accetto <span style="color:#F00">*</span>
<input type="submit" disabled="true" id="Invio" value=" Invia richiesta ">
<span style="font-size:12px">
I campi con (<span style="color:#F00">*</span>) sono obbligatori e per inviare la richiesta bisogna accettare l'informativa.
</span>
</td>
</tr>
</table>
</form>
</body>
</html>