Link to home
Start Free TrialLog in
Avatar of Projack
Projack

asked on

Validating date (12/31/2008 12:00:00 AM) with regular expression validator

The tag below validate date with mm/dd/yy format but cold not validate date such as this 12/31/2008 12:00:00 AM. How can I modify the tag to validate date such as this 12/31/2008 12:00:00 AM
<asp:RegularExpressionValidator ID="RegularValidatorEndDate" runat="server" ControlToValidate="txtEndDate"
                        ErrorMessage="Enter a valid End Date (i.e. mm/dd/yy)" ValidationExpression="^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{2}$"
                        Display="Dynamic"></asp:RegularExpressionValidator>

Open in new window

Avatar of Daniel Wilson
Daniel Wilson
Flag of United States of America image

Use a CompareValidator instead of a RegularExpresionValidator.  use the DataTypeCheck operator to require that it's a Date.

That will work MUCH better!
Avatar of Projack
Projack

ASKER

I add no problem with date as I stated that this (mm/dd/yy worked without broblem The issue is how do I use the CompareValidator to validate 12/31/2008 12:00:00 AM format
ASKER CERTIFIED SOLUTION
Avatar of GiftsonDJohn
GiftsonDJohn
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial