ti ringrazio, ma convalida anche date future, sono su IE 6:
codice:
<html>
<head>
<script language="javascript" type="text/javascript">
<!--
function checkDate(dateObj)
{
var dt = dateObj.value.match(re);
if (!dt)
{
alert("La data va inserita nel formato gg/mm/aaaa !");
return(false);
}
day = dt[1];
month = dt[2];
year = dt[3];
if (month < 1 || month > 12)
{
alert("Specificare un mese compreso tra 1 e 12 !");
return(false);
}
// Determina il numero massimo di giorni nel mese month
// Il calendario in uso è quello Gregoriano (introdotto da Papa Gregorio XIII nel 1582)
// ed ha un ciclo di 400 anni con 97 anni bisestili anziché 100.
// Il 1600 era bisestile, 1700, 1800 e 1900 no, il 2000 lo è, 2100, 2200, 2300 no etc.
if (month == 2) maxDay = (!(year % 4) && ((year % 100) || !(year % 400))) ? 29 : 28;
else maxDay = (month == 4 || month == 6 || month == 9 || month == 11) ? 30 : 31;
if (day < 1 || day > maxDay)
{
alert("Il mese di " + arrMonths[month - 1] + " non ha " + day +
" giorni\nSpecificare un giorno compreso tra 1 e " + maxDay + " !");
return(false);
}
var now = new Date();
now.setHours(0);
now.setMinutes(0);
now.setSeconds(0);
var theDate = new Date(year, month - 1, day, 0, 0, 0);
if(now.getTime < theDate.getTime())
{
alert("Hai scelto una data futura");
return false;
}
return(true);
}
function convalidaForm(Qform)
{
var i=0,Q= Qform.elements,L=Q.length;
for (var a = 0; a < L; a++){
var campo = Q[a];
if( campo.value===''){
campo.style.backgroundColor='orange';
++i;
}
else campo.style.backgroundColor='';
}
if(i){
alert('I campi segnalati sono obbligatorio in questo form.');
return false;
}
// Controlla data_evento
if (!checkDate(Qform.data_evento))
{
Qform.data_evento.focus();
Qform.data_evento.select();
return(false);
}
//tutto OK
return(true);
}
//-->
</script>
</head>
<body>
<form method="POST" action="" onsubmit="return(convalidaForm(this));">
<input type="text" name="data_evento" size="20">
<input type="submit" value="Invia" name="B1"><input type="reset" value="Reimposta" name="B2"></p>
</form>
</body>
</html>