Regular Expression not working

i am using following regular expression validator, but it not working with the date 19-Feb-2013
it is saying invalid date ? But it is validating 19-Feb-2012. Why this issue ? How do i solve ?

Varshini SAsked:
Who is Participating?
Shaun KlineConnect With a Mentor Lead Software EngineerCommented:
Define "not validating". Do you mean it is allowing that date?
Shaun KlineConnect With a Mentor Lead Software EngineerCommented:
This issue is at the end of the expression:
This allows days of 01-09, 10-18 and 20-28 for non-leap year days in Feb.
Look to change this to [0][1-9]|[1][0-9]|[2][0-8]
BenefordConnect With a Mentor Commented:
re says:
1-31 [Jan|Mar|May|Jul|Aug|Oct|Dec] any year
1-30 any month except Feb
1-29 Feb any year ending [02468][048] or ending [13579][26]
1-28 Feb any year

The problem is the formulation of 1-28 which actually says [12][0-8] which excludes 19.
the 1-28 condition should be

Actually, the formula would probably be better with 1-28 before (just) the 29 Feb logic.
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Varshini SAuthor Commented:
Thank you, it is working but if i give the date 29-Feb-2013 - it is not validating. Why ?

has regular expressions for almost anything.  There is one on there that does exactly what you want.  Look under Date/Time.

käµfm³d 👽Commented:
Why use a regex for date validation? Why not use a CompareValidator?

e.g.  (

    id="dateValidator" runat="server" 
    ErrorMessage="Please enter a valid date.">

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.