Hello Friends
I am using ASP.Net Textbox for date input. I want to validate the date. For this i am using Regular Expression. The validate expression is;
ValidationExpression=”^(d{0}|(31(?!(Feb|feb|Apr|apr|Jun|jun|Sep|
sep|Nov|nov)))|((30|29)(?!Feb|feb))|(29(?=Feb|feb(((1[6-9]|[2-9]\
d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00
)))))|(29(?=Feb|feb(((0[48]|[2468][048]|[13579]
[26])|((16|[2468][048]|[3579][26])00)))))|(0?[1-9])|1\d|2[0-8])[- ](Jan|jan|feb|Feb|mar|Mar|may|May|apr|Apr|jul|Jul|Jun|jun|Aug|aug|
Oct|oct|Sep|sep|Nov|nov|dec|Dec)[- ]((1[6-9]|[2-9]\d)\d{2}|\d{2}|d{0})$”
But its not working properlly.
Niradhip ChakrabortyPosted Dec 18, 2008, 8:13 AM
^[0-9]{4}-(((0[13578]|(10|12))-(0[1-9]|[1-2][0-9]|3[0-1]))|(02-(0[1-9]|[1-2][0-9]))|((0[469]|11)-(0[1-9]|[1-2][0-9]|30)))$
Matches the yyyy-mm-dd date format and also validates month and number of days in a month. Could be improved as currently all leap year dates (yyyy-02-29) will validate.