Solved

Regular expression to validate date

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Unknown server tag 'ajaxToolkit:toolkitscripmanager' 6 38
call function 8 40
popup message 3 26
JavaScript error 1 33
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…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

707 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

13 Experts available now in Live!

Get 1:1 Help Now