473,326 Members | 2,337 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

RegularExpression code for server-side validation of Date

mg
Does someone have RegularExpression code (C# WebForm) for server-side validation of Date (mm/dd/yyyy) ... including leap year?
Nov 16 '05 #1
1 2771
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.com

"mg" <mg@theworld.com> wrote in message
news:99**********************************@microsof t.com...
Does someone have RegularExpression 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
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 '?'....
4
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...
4
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...
2
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...
4
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...
1
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...
2
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
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...
1
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...
1
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.