Solved

Regular expression to validate date

Posted on 2010-08-30
4
408 Views
Last Modified: 2012-05-10

I need to use a reglualr expression to validate date in mm/dd/yyyy format. This link does it in dd/mm/yyyy formart. How can do it in mm/dd/yyyy format?

http://forums.asp.net/t/1567580.aspx

 <asp:RegularExpressionValidator ID="RegularExpressionValidator5" runat="server"  
                                     
                                     Text="MM/DD/YYYY"  
                                    ErrorMessage="*"
                                    ControlToValidate="txtAvailableDate"    
                                    ValidationExpression="" />
             
0
Comment
Question by:Camillia
  • 2
4 Comments
 
LVL 10

Accepted Solution

by:
Jini Jose earned 500 total points
ID: 33560932
use the rad software regular expression validator designer to build your own expressions. it is a free tool.
0
 
LVL 7

Author Comment

by:Camillia
ID: 33560960
no, there has to be some regex out there to do mm/dd/yyyy
0
 
LVL 10

Expert Comment

by:Jini Jose
ID: 33560977
just try the tool..
0
 
LVL 2

Expert Comment

by:Fahad Pathan
ID: 33561167
try this..

 <asp:RegularExpressionValidator ID="RegularExpressionValidator5" runat="server"  
                                     Text="MM/DD/YYYY"  
                                    ErrorMessage="*"
                                    ControlToValidate="txtAvailableDate"    
                                    ValidationExpression="^(|(0[1-9])|(1[0-2]))\/((0[1-9])|(1\d)|(2\d)|(3[0-1]))\/((\d{4}))$" />

Expression      ^(|(0[1-9])|(1[0-2]))\/((0[1-9])|(1\d)|(2\d)|(3[0-1]))\/((\d{4}))$

Description      This expression matches dates formatted as MM/DD/YYYY where months and days must be 2 digits each, zero padded. It is not perfect - it allows DD to be from 01 to 31 regardless of the month.

Matches      01/01/2001 | 02/30/2001 | 12/31/2002

Non-Matches      1/1/02 | 1/1/2002 | 1/25/2002

For more validators bookmark this website..
http://www.regexlib.com/

Dont forget to make anwer...
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question