You're still better off using JavaScript. For example:
//Check for Invalid Dates
function testKey(e){
chars= "0123456789/";
e = window.event;
if(chars.indexOf(String.fromCharCode(e.keyCode))==-1)
window.event.keyCode=0;
};
function valDate(M, D, Y){
Months= new Array(31,28,31,30,31,30,31,31,30,31,30,31);
Leap = false;
if((Y % 4 == 0) && ((Y % 100 != 0) || (Y %400 == 0)))
Leap = true;
if((D < 1) || (D > 31) || (M < 1) || (M > 12) || (Y < 0))
return(false);
if((D > Months[M-1]) && !((M == 2) && (D > 28)))
return(false);
if(!(Leap) && (M == 2) && (D > 28))
return(false);
if((Leap) && (M == 2) && (D > 29))
return(false);
};
function formatDate(dateForm){
cDate = dateForm.value;
dSize = cDate.length;
sCount= 0;
if(cDate=='') return;
//Check out the slashs
for(var i=0; i < dSize; i++)
(cDate.substr(i,1) == "/") ? sCount++ : sCount;
if (sCount != 2){
alert("The Date must be in the format\n ''DD/MM/YYYY''");
dateForm.select();
return(false);
};
//Check if the year is a 2 or 4 digits string
ySize = cDate.substring(cDate.lastIndexOf("/")+1,dSize).length
if(ySize<2 || ySize>4 || ySize == 3){
alert("You've entered an Invalid Date");
dateForm.select();
return false;
};
//Cut the date string into three parts (Month, Day & Year)
idxBarI = cDate.indexOf("/");
idxBarII= cDate.lastIndexOf("/");
strM = cDate.substring(0,idxBarI);
strD = cDate.substring(idxBarI+1,idxBarII);
strY = cDate.substring(idxBarII+1,dSize);
strM = (strM.length < 2 ? '0'+strM : strM);
strD = (strD.length < 2 ? '0'+strD : strD);
if(strY.length == 2)
strY = (strY > 50 ? '19'+strY : '20'+strY);
dateForm.value = strM+'/'+strD+'/'+strY;
ok = valDate(strM, strD, strY);
if(ok==false){
alert("You've entered an Invalid Date");
dateForm.select();
return false;
};
};
Then add it to your field like this:
<input type="text" name="Date" onBlur="formatDate(this)"
onKeyPress="testKey(event)" size="10">