Solved

Regular expression to validate date

Posted on 2010-08-30
4
411 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

734 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