Click here to Skip to main content
15,921,941 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to validate date using Regular Expression Validator to my text box. TextBox should allow this format only YYYY-MM-DD.

could any body tell me....
Posted
Updated 16-Apr-14 19:04pm
v2
Comments
PIEBALDconsult 17-Apr-14 1:33am    
Have you considered a DateTimePicker instead?

1 solution

try this expression in your validation expression

^\d{4}-((0\d)|(1[012]))-(([012]\d)|3[01])$

:)
 
Share this answer
 
v2
Comments
Venkat Kumar chigulla 17-Apr-14 1:27am    
One More thing i left, Text box should allow only Time, and the time format is 06:00, 12:00, 18:00, 24:00, 16:30, 14:30, 06:30 like this...
Sanket Saxena 17-Apr-14 1:31am    
In the same text box or you have another one for time?
Venkat Kumar chigulla 17-Apr-14 1:32am    
Some other TextBox... Time should be like above Format
Sanket Saxena 17-Apr-14 1:34am    
try this:
ValidationExpression="^(1[0-2]|0[1-9]):[0-5][0-9]\040(AM|am|PM|pm)$"
Venkat Kumar chigulla 17-Apr-14 1:41am    
Thank a lot... Both Expressions Reached my Requirement.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900