Ragazzi ho risolto così:
codice:
<script language="javascript">
<!--
function Modulo() {
// Variabili associate ai campi del modulo
var data = document.modulo.data.value;
var numero = document.modulo.numero.value;
//Effettua il controllo sul campo NUMERO
if ((isNaN(numero)) || (numero == "undefined")) {
alert("Il campo Numero deve contenere un valore numerico.");
document.modulo.numero.value = "";
document.modulo.numero.focus();
return false;
}
else if (data != ""){
//Effettua il controllo sul campo DATA
if (document.modulo.data.value.substring(2,3) != "/" ||
document.modulo.data.value.substring(5,6) != "/" ||
isNaN(document.modulo.data.value.substring(0,2)) ||
isNaN(document.modulo.data.value.substring(3,5)) ||
isNaN(document.modulo.data.value.substring(6,10))) {
alert("Inserire Data in formato gg/mm/aaaa");
document.modulo.data.value = "";
document.modulo.data.focus();
return false;
}
else if (document.modulo.data.value.substring(0,2) > 31) {
alert("Impossibile utilizzare un valore superiore a 31 per i giorni");
document.modulo.data.select();
return false;
}
else if (document.modulo.data.value.substring(3,5) > 12) {
alert("Impossibile utilizzare un valore superiore a 12 per i mesi");
document.modulo.data.value = "";
document.modulo.data.focus();
return false;
}
else if (document.modulo.data.value.substring(6,10) < 1900) {
alert("Impossibile utilizzare un valore inferiore a 1900 per l'anno");
document.modulo.data.value = "";
document.modulo.data.focus();
return false;
}
else {
document.modulo.action = "view.php";
document.modulo.submit(); }
}
//INVIA IL MODULO
else {
document.modulo.action = "view.php";
document.modulo.submit();
//document.write(document.modulo.data.value);
}
}
//-->
</script>