Date Validation Expression and Leap Year

H

Hai Nguyen

I want to validate a textbox with date in the right format. I already have
it worked. However, my validation expression does not solve the # of days in
Feb; for isntance it does not solve for leap year like on Feb there are
maybe 28 or 29 days

Thank for any help
 
H

Hans Kesting

Hai Nguyen said:
I want to validate a textbox with date in the right format. I already have
it worked. However, my validation expression does not solve the # of days in
Feb; for isntance it does not solve for leap year like on Feb there are
maybe 28 or 29 days

Thank for any help

I am guessing (as you didn't specify it) that you are using a
RegularExpressionValidator
and that you want a RE that correctly checks for leapdays.
That can't be done (or at least not without a very complicated RE).
You already have a RE that checks if the string "looks like it could be a
date".
You could add a CustomValidator with server-side code that checks if it is
a real date ("does DateTime.Parse accept it?") and even add a client-side
function that does the same.

Hans Kesting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top