I wanna validate date which can be either in short date format or long date format.
eg: for some of the valid date.
12/05/2010 , 12/05/10 , 12-05-10, 12-05-2010
var reLong = /d{1,2}[/-]d{1,2}[/-]d{4}/;
var reShort = /d{1,2}[/-]d{1,2}[/-]d{2}/;
var valid = (reLong.test(entry)) || (reShort.test(entry));
if(valid)
{
return true;
}
else
{
return false;
}
but this current regular expression fails when i try to give an invalid date as 12/05/20-0
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…