Solved

Regular expression to validate date

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

821 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