Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have a calender extender in that i have to fix date format as Indian format like 27/01/2011
means dd/mm/yyyy and i want to validate it regular expression validation. Previously i fixed the
format as 27/Jan/2011 and it's getting validate but I have to validate as above.
If anybody knows let me know .


Lots of thanks in advance
Mohammad Wasif
Posted

set calendar extender property Format="dd/MM/yyyy"
dd/mm/yyyy format[^]
 
Share this answer
 
Comments
Mohd Wasif 25-Jan-11 2:45am    
Thanks but on click event of button
protected void Button1_Click(object sender, EventArgs e)
{
DateTime Dob = Convert.ToDateTime(TextBox2.Text);

}

it's showing error as: String was not recognized as a valid DateTime.
m@dhu 25-Jan-11 2:58am    
you need to change the date format to mm/dd/yyyy.
Use the following regular expression to validate the date in "27/Jan/2011" format and then convert it to datetime.


((3[01]|[12][0-9]|0?[1-9]))([/])(Jan|Feb|Mar|Apr|May|Jun|Jul|Apr|Sep|Oct|Nov|Dec)([/])(\d{4}$)
 
Share this answer
 
v2
Comments
m@dhu 25-Jan-11 5:08am    
Please read the question carefully. The op wants the regular expression for dd/MM/yyyy format and not for 27/Jan/2011 format.
raghu.g 25-Jan-11 6:26am    
Oh, I misunderstood the question.

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