Date Validation Expression and Leap Year

  • Thread starter Thread starter Hai Nguyen
  • Start date Start date
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
 
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
 
Back
Top