Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 26th, 2006, 06:26 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default I am stuck a bit, help friends/dparsons

Hi

I have the regular expression to validate date (mm/dd/yyyy) with <asp:regularexpressionvalidator> but its not validating leap years, can anyone help with the regex, the code that I am using is as below:

<asp:regularexpressionvalidator id="regExpRequestDate" runat="server" ControlToValidate="txtRequestDate" ErrorMessage="(mm/dd/yyyy format)"
                                ValidationExpression="^[0-2]?[1-9](/|-)[0-3]?[0-9](/|-)[1-2][0-9][0-9][0-9]$"></asp:regularexpressionvalidator>

Regards
Mike
__________________
Regards
Mike
 
Old October 26th, 2006, 06:51 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Oops!

No need to worry friends, I sorted it out, I used the compareValidator to check date, thanx for your efforts.

Regards
Mike
 
Old October 26th, 2006, 07:29 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Here you go anyway! This will check a valid date as well as a leap year. excepts date as d.m.yy or dd/mm/yy etc.
^((((0?[1-9]|[12]\d|3[01])[\.\-\/](0?[13578]|1[02])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|[12]\d|30)[\.\-\/](0?[13456789]|1[012])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|1\d|2[0-8])[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|(29[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00)))|(((0[1-9]|[12]\d|3[01])(0[13578]|1[02])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|[12]\d|30)(0[13456789]|1[012])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|1\d|2[0-8])02((1[6-9]|[2-9]\d)?\d{2}))|(2902((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00))))$

-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.

^^Thats my signature
 
Old October 26th, 2006, 10:23 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Thanx Parsons

This works as well :)

Regards
Mike





Similar Threads
Thread Thread Starter Forum Replies Last Post
Hi,Friends emmanuelmosses Crystal Reports 1 August 25th, 2008 12:38 PM
Hi friends help me vingo_mail ASP.NET 2.0 Professional 1 March 12th, 2008 07:35 AM
Help Required in Mail / dparsons balesh ASP.NET 1.0 and 1.1 Professional 3 November 6th, 2006 08:18 AM
64 Bit - Issue in 64 bit IIS calling Win32 API Hubman General .NET 1 August 24th, 2006 09:19 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.