RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
((^(10|12|0?[13578])([/])(3[01]|[12][0-9]|0?[1-9])([/])((1[8-9]\d{2})|([2-9]\d{3}))$)|(^(11|0?[469])([/])(30|[12][0-9]|0?[1-9])([/])((1[8-9]\d{2})|([2-9]\d{3}))$)|(^(0?2)([/])(2[0-8]|1[0-9]|0?[1-9])([/])((1[8-9]\d{2})|([2-9]\d{3}))$)|(^(0?2)([/])(29)([/])([2468][048]00)$)|(^(0?2)([/])(29)([/])([3579][26]00)$)|(^(0?2)([/])(29)([/])([1][89][0][48])$)|(^(0?2)([/])(29)([/])([2-9][0-9][0][48])$)|(^(0?2)([/])(29)([/])([1][89][2468][048])$)|(^(0?2)([/])(29)([/])([2-9][0-9][2468][048])$)|(^(0?2)([/])(29)([/])([1][89][13579][26])$)|(^(0?2)([/])(29)([/])([2-9][0-9][13579][26])$))
Description
This Validator Validates any date from 1800 - 9999. It takes special care of Leap years and validates any format of type mm/dd/yyyy , m/dd/yyyy , mm/d/yyyy , m/d/yyyy. Since SQL Server does not accept any date before 1/1/1753, so i hope it will meet Your Requirements.(Modified Version of Jason West's Date Validator.)
Matches
2/2/2000 | 02/02/2000 | 02/2/2000
Non-Matches
2.2.2000 | 2-2-2000
Author Rating: The rating for this expression. Saurabh Nath
Source
Your Rating
Bad Good

Enter New Comment

Title

Name

Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: Fails on Month 11 (November)
Name: John Hunt
Date: 2/20/2015 1:21:11 PM
Comment:
It's not accepting 11/1/2015 | 11/10/2015


Title: So good I blogged about it
Name: Greg Finzer
Date: 3/3/2014 5:23:31 PM
Comment:
Saurabh, I just wanted to let you know that I think this regular expression is so incredible, that I blogged about it. Thanks so much! http://sogetigeeks.blogspot.com/2014/03/Regular-Expression-Parses-Leap-Years.html


Title: How to add Year range from 1900-1999
Name: RS
Date: 1/13/2011 3:25:35 PM
Comment:
How to add year range 1900-1999 to above regular expression


Title: How to add Year range from 1900-1999
Name: RS
Date: 1/13/2011 3:25:24 PM
Comment:
How to add year range 1900-1999 to above regular expression


Title: Thanks
Name: Vlad Orlovsky
Date: 9/10/2010 4:33:31 PM
Comment:
Thanks, worked great in SQL Server 2000.


Title: Date format for UK dd/mm/yyyy
Name: Joe
Date: 9/1/2009 6:10:43 AM
Comment:
Could you please provide a modified version of your date validator for UK formatted dates, dd/mm/yyyy.


Title: Need Regular Expression to check for dates with range 1753 to 9999 (mm/dd/yyyy)
Name: Naveen
Date: 9/12/2008 12:37:48 AM
Comment:
Need Regular Expression to check for dates with range 1753 to 9999 (mm/dd/yyyy)


Title: Need Regular Expression to check for dates with range 1753 to 9999 (mm/dd/yyyy)
Name: Naveen
Date: 9/12/2008 12:24:31 AM
Comment:
Need Regular Expression to check for dates with range 1753 to 9999 (mm/dd/yyyy)


Title: Wonderful
Name: Kaladharan
Date: 3/20/2008 7:22:46 AM
Comment:
This is a wondeful job done by Surabh. This reges is very useful for me. Thanks a lot


Title: Developer
Name: Jason
Date: 1/29/2008 1:21:13 AM
Comment:
Perfect. A little long but handles just about everything stupid users can throw at it.


Title: Wonderful
Name: Parth Dave
Date: 9/20/2007 3:31:14 AM
Comment:
It's what i expected and was finding for a long.. thanks


Title: Cannot make this work
Name: Trey Guy
Date: 8/3/2007 2:44:19 PM
Comment:
No matter what value I pass to this expression, it always returns false. Could anyone point out my error. Code below. function CheckMyDate(VarName){ var VarVal = VarName.value; var rx = new RegExp("((^(10|12|0?[13578])([/])(3[01]|[12][0-9]|0?[1-9])([/])((1[8-9]\d{2})|([2-9]\d{3}))$)|(^(11|0?[469])([/])(30|[12][0-9]|0?[1-9])([/])((1[8-9]\d{2})|([2-9]\d{3}))$)|(^(0?2)([/])(2[0-8]|1[0-9]|0?[1-9])([/])((1[8-9]\d{2})|([2-9]\d{3}))$)|(^(0?2)([/])(29)([/])([2468][048]00)$)|(^(0?2)([/])(29)([/])([3579][26]00)$)|(^(0?2)([/])(29)([/])([1][89][0][48])$)|(^(0?2)([/])(29)([/])([2-9][0-9][0][48])$)|(^(0?2)([/])(29)([/])([1][89][2468][048])$)|(^(0?2)([/])(29)([/])([2-9][0-9][2468][048])$)|(^(0?2)([/])(29)([/])([1][89][13579][26])$)|(^(0?2)([/])(29)([/])([2-9][0-9][13579][26])$))"); if (rx.test(VarVal)){ alert("Good date"); } else{ alert("Bad date"); } }


Title: Beginner
Name: Janet
Date: 11/15/2006 11:30:35 AM
Comment:
Tried many versions and got errors or wouldn't validate leap years. Thanks so much for sharing this expression so that we "newbies" can learn....


Title: Developer
Name: Keerthi ram
Date: 7/5/2006 8:24:09 AM
Comment:
Excellent expression!


Title: Developer
Name: Keerthi ram
Date: 7/5/2006 7:55:02 AM
Comment:
Excellent expression! Thanks...


Title: Developer
Name: Keerthi ram
Date: 7/5/2006 7:50:07 AM
Comment:
Excellent expression! Thanks...


Title: Cool job, Thanks!
Name: David
Date: 9/16/2005 2:37:53 AM
Comment:
Thanks for your cool job!!!


Title: Date Validator
Name: John Weaver
Date: 4/20/2005 4:49:05 PM
Comment:
BEAUTIFUL! Just what I wanted and it works just fine!


Title: Great Expression
Name: Paul E. Valadez
Date: 10/12/2004 5:38:09 PM
Comment:
Great expression just what I was looking for !!!!


Title: Many Thanks
Name: S.Walther
Date: 4/9/2004 4:51:25 AM
Comment:
I tried hard for searching a dd/mm/yyyy validator and this one is simply perfect. Many thanks, works Absolutely as desired.


Title: Developer
Name: James V
Date: 4/9/2004 4:47:47 AM
Comment:
Really, works to perfection. Great work.


Title: Thank you! #279 , 504 & 505 I think
Name: Bill
Date: 4/8/2004 4:20:20 PM
Comment:
2 days trying to find a javascript mm/dd/yyyy validator and here you have the whole thing. I tried your new version, but got a syntax error on my IE 6.0.2800.1106 with SP1 and security updates so I went back to # 279. Now off trying to put it in a .js Thanks again.


Title: Does not work as expected
Name: Vandevyvere Martijn
Date: 4/8/2004 9:48:39 AM
Comment:
Tried to validate the following date, but failed: [30/12/2044]


Title: Developer
Name: T.Hulsey
Date: 1/8/2004 5:35:24 PM
Comment:
Verbose, but works nicely. Thanks.


Title: Date Validator
Name: Saurabh Nath Sharma
Date: 4/7/2003 1:53:42 AM
Comment:
Date Validator from 1/1/1800 - 12/31/9999 which SQL Server 2000 Accepts.


Copyright © 2001-2024, RegexAdvice.com | ASP.NET Tutorials