Con questo script controllo l'esatta compilazione dei campi di un form; se volessi inserire un controllo sul campo data del form anche sui caratteri utilizzati (per esempio permettere soltanto l'utilizzo di / come separatore di gg/aa/mm) come procedo?
codice:
<script language="JavaScript">
<!--
function submitIt(theform) {
if (theform.Nome.value == "") {
alert("Manca un dato...");
theform.Nome.focus();
return false;
}
if (theform.Cognome.value == "") {
alert("Manca un dato...");
theform.Cognome.focus();
return false;
}
if (theform.Citta.value == "") {
alert("Manca un dato...");
theform.Citta.focus();
return false;
}
if (theform.Stato.value == "") {
alert("Manca un dato...");
theform.Stato.focus();
return false;
}
if ((theform.Email.value =="")||
(theform.Email.value.indexOf("@") == -1) ||
(theform.Email.value.indexOf(".") == -1) ||
(theform.Email.value.length < 7))
{
alert("Manca un dato...");
theform.Email.focus();
return false;
}
}
-->
</script>