Solved

Regular expression to validate date

Posted on 2010-08-30
4
407 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
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…

863 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

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now