Prova:
codice:
<html> 
<head> 
<title>...</title> 
<script>
function s(x){
if(/^[0-9]{2}(\-|\/)[0-9]{2}(\-|\/)[0-9]{4}$/.test(x)) {

	x = x.replace("/","-");
	x = x.replace("/","-");
	x = x.split("-");
	if((x[0]>31)|(x[1]>12))alert("Formato data errato")
	}
else alert("Formato data errato")
}
</script>
</head> 
<body> 
<input type="text" onBlur="s(this.value)">
</body>
</html>
Formato gg/mm/aaaa o gg-mm-aaa