473,396 Members | 2,011 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,396 software developers and data experts.

Help on Regular experession to validate date

Hi,

I want to use RegularExpressionValidator to validate a date

I want to let user to enter date in the following format

one or two digits for day
one or two digits for month
two or four digits for year
User should be allowed to use as date Separator either . or - or /

So this should be valid date

1/11/03
21.5.2004
3-11-00

If I use the following regular expression it allows only . as date separator
\d{1,2}\.\d{1,2}\.(\d{2}|\d{4})
I tryed the following sequence for separator, to allow any of the three I
mention above, but it doesn't works.
(\.|\-|\/)
I tried with the following one too
(.|-|/)
None of them are working

Can anyone tell me what I did wrong?

Thank you.
Bogdan


Nov 17 '05 #1
2 3272

"Bogdan Zamfir" <ams_soft at pcnet dot ro> wrote in message
news:Oi**************@TK2MSFTNGP12.phx.gbl...
Hi,

I want to use RegularExpressionValidator to validate a date

I want to let user to enter date in the following format

one or two digits for day
one or two digits for month
two or four digits for year
User should be allowed to use as date Separator either . or - or /

So this should be valid date

1/11/03
21.5.2004
3-11-00

If I use the following regular expression it allows only . as date separator \d{1,2}\.\d{1,2}\.(\d{2}|\d{4})
I tryed the following sequence for separator, to allow any of the three I
mention above, but it doesn't works.
(\.|\-|\/)
I tried with the following one too
(.|-|/)
None of them are working

Can anyone tell me what I did wrong?

Thank you.
Bogdan


try this
\d{1,2}[-./]\d{1,2}[-./](\d{2}|\d{4})

the "[-./]" part matches one of "-" , '." or "/". Take care: within [] the -
is also a special
character to signal a range.( [a-z] is "lowercase letter between a and z").
Only as first
or last character it is recognised as a "minus".

Hans Kesting

Nov 17 '05 #2

"Bogdan Zamfir" <ams_soft at pcnet dot ro> wrote in message
news:Oi**************@TK2MSFTNGP12.phx.gbl...
Hi,

I want to use RegularExpressionValidator to validate a date

I want to let user to enter date in the following format

one or two digits for day
one or two digits for month
two or four digits for year
User should be allowed to use as date Separator either . or - or /

So this should be valid date

1/11/03
21.5.2004
3-11-00

If I use the following regular expression it allows only . as date separator \d{1,2}\.\d{1,2}\.(\d{2}|\d{4})
I tryed the following sequence for separator, to allow any of the three I
mention above, but it doesn't works.
(\.|\-|\/)
I tried with the following one too
(.|-|/)
None of them are working

Can anyone tell me what I did wrong?

Thank you.
Bogdan


try this
\d{1,2}[-./]\d{1,2}[-./](\d{2}|\d{4})

the "[-./]" part matches one of "-" , '." or "/". Take care: within [] the -
is also a special
character to signal a range.( [a-z] is "lowercase letter between a and z").
Only as first
or last character it is recognised as a "minus".

Hans Kesting

Nov 17 '05 #3

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

Similar topics

1
by: dcinfinite | last post by:
hi.. i have a few other questions 2 ask..i used the "calender" function to insert Date of Birth for my "add customer form" is that advisible?coz i feel it'll be easy for customers to just click...
6
by: paulsmith5 | last post by:
Hi, I have the following regular expression to validate a date-time field in European or d/m/y h:m:s format. ...
2
by: Christian Staffe | last post by:
Hi, I would like to check for a partial match between an input string and a regular expression using the Regex class in .NET. By partial match, I mean that the input string could not yet be...
4
by: Frank Rocco | last post by:
Hello, What is the best way to validate a textbox to see if it contains a valid date or a valid time or both? Thanks Frank
0
by: Bogdan Zamfir | last post by:
Hi, I want to use RegularExpressionValidator to validate a date I want to let user to enter date in the following format one or two digits for day one or two digits for month two or four...
18
by: Q. John Chen | last post by:
I have Vidation Controls First One: Simple exluce certain special characters: say no a or b or c in the string: * Second One: I required date be entered in "MM/DD/YYYY" format: //+4 How...
22
by: deepak.rathore | last post by:
can someone give the regular expr. to validate leap yr like 02/29/2000,02/29/00 Thanks
6
by: Wayne Wengert | last post by:
I hope this is an appropriate group for this question - if not, let me know where I should take this question. I want a regular expression that will validate a date in the format mm/dd/yyyy. I...
3
by: samuelberthelot | last post by:
Hello, I would like to validate a date in a textbox on the onChange event. The date must be in the format 01/01/2007 I would like to use a regular expression to validate it but I'm not very...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...
0
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,...

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.