Prova così
codice:<html> <head> <title>...</title> <SCRIPT> var min=1900; var max=2003; function ch(x){ if(/^[0-9]{4}$/.test(x)){ if(x<min)alert("data troppo vecchia") else if(x>max)alert("data troppo recente"); } else alert("Inserire anno in formato aaaa"); } </SCRIPT> </head> <BODY> <input type="text" onBlur="ch(this.value)"> </body> </html>