473,748 Members | 7,827 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RegularExpressi on code for server-side validation of Date

mg
Does someone have RegularExpressi on code (C# WebForm) for server-side validation of Date (mm/dd/yyyy) ... including leap year?
Nov 16 '05 #1
1 2793
mg,

Instead of using a regular expression, why not try the Parse method on
the DateTime class? You can pass in any date time format that you want, and
it should parse it apart. It will throw an exception which you can trap, if
the format is not valid. Granted, this is expensive. The new version of
..NET will have a TryParse method, which will let you know if the string
matches the format you specify.

Using Parse/TryParse prevents you from having to know the regular
expression syntax and just the format that you want to be able to parse.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"mg" <mg@theworld.co m> wrote in message
news:99******** *************** ***********@mic rosoft.com...
Does someone have RegularExpressi on code (C# WebForm) for server-side

validation of Date (mm/dd/yyyy) ... including leap year?
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1848
by: Greg | last post by:
Standar 9-digit postal code expression, copied and pasted from a web form validator expression: @"\d{5}(-\d{4})? I try to use it to validate a windows textbox, but it does not like the '?'. If the first part is matched,it doesnt care what comes afterwards. Removing the ? gives proper behavior.
4
1280
by: Learning SQL Server | last post by:
The email reg exp that ships with the RegularExpressionValidator doesnt like this email address: user@blah.ru Or any other email domain that contains only 2 letters after the dot. It *looks* like it should (I notice the qualifier at the end of the statement for 2 or more letters), but the validator always fires anyway. Anyone else notice similar behavior or do I just need some sleep?
4
2209
by: Chris | last post by:
I work on a development server (Server A), and have a staging server (Server B), where updated ASP.Net files from Server A are sent to. I noticed that Server B will reflect changes made to .aspx files just by copying the new files from Server A. Server B only has the framework installed, and the project folder structure is enormous (100MB+). I know that I can rebuild the project on Server A, which has .Net Studio, and copy the new...
2
3110
by: Ric | last post by:
im new to asp.net. from what i understand, you have the aspx file (presentation), user-control(ascx file), code-behind(vb file) and components(compiled vb and dll files). the aspx file contains a reference to the ascx which can contain a reference to a component. can an aspx file contain a reference to an ascx file which contains a reference to a code-behind file? ive tried to do this then load the user-control via LoadControl(), but i...
4
1311
by: Kenneth P | last post by:
Hi, I have a .aspx file named testConnStr.aspx witin a try, catch, finally block that works just very nice, shows the data in a datagrid. I have one header saying "test ConnStr" and two server objects, a label and a datagrid. So I decided to do it with code behind. What happens?
1
1053
by: fabrice | last post by:
Hello, In a search form, i want to permit few characters (see below) and some signs as - _ / , . So thios my RegularExpression and it works. ValidationExpression="{4,20}" But i'd would like to permit the sign ? in my string, but only one or two
2
1231
by: Fabio | last post by:
Hi all, I have this simple string for example: anything<font>catch this</font> and I need a regularexpression to Catch "catch this" so, I can use this pattern: ">+"
3
1751
by: Arpan | last post by:
Consider the following code which validates a TextBox using RegularExpression: <form id="form1" runat="server"> <asp:TextBox id="txt1" runat="server"/> <asp:RegularExpressionValidator ControlToValidate="txt1" ValidationExpression="{5}-{4}|{5}" ErrorMessage ="Invalid Input" Display="Dynamic" runat="server"/> <asp:Button id="btn" Text="SUBMIT" runat="server"/> </form>
1
1528
by: Arpan | last post by:
Using RegularExpression, I want to validate a TextBox so that the TextBox accepts only 8-digit numbers. This can be done with the following RegularExpression: {8} But how do I validate the TextBox so that it accepts 8-digit number or more than 8-digit numbers using RegularExpressions? Also how do I validate the TextBox so that it accepts 8 or more than
1
2038
by: prp | last post by:
hi all, I have a problem.Suppose I use a regularexpression validator for zip code. An User fill wrong entry in the relevant textbox then regularexpression validator fires.but user did not correct the entry and press the signup button . At that time i want setfocus on that zip textbox. all such things happen in asp.net and i want javascript for the setfocus.
0
8826
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9316
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9241
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8239
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4867
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3303
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2777
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.