RegularExpresionValidator for date

  • Thread starter Thread starter Atul Rane
  • Start date Start date
A

Atul Rane

I want to restrict user to select received date greater then todays date
using RegularExpresionValidator for this i want regular expression.
 
Atul,

I am curious, why not normal methods?

Seems to me a little bit strange, (or your teacher should have asked of
course this to you, and it is good practise in the .Net newsgroups not to
help with homework)

:-)

Cor
 
Atul Rane said:
I want to restrict user to select received date greater then todays date
using RegularExpresionValidator for this i want regular expression.

Selecting a date "greater than todays date" is going to be very
difficult with a regular expression. Instead you can use a CompareValidator,
which lets you specify a ValueToCompare (that you can set to today's date in
code), an Operator which you can set to "greater than", and a Type that you
can set to "Date".
 
It happens that Atul Rane formulated :
I want to restrict user to select received date greater then todays date
using RegularExpresionValidator for this i want regular expression.

That is impossible: regex knows nothing about "dates" or "numbers", it
only deals with "strings".

With a somewhat simple expression you could forbid "very illegal"
dates, like day 43 or month 21. Using a bit more complex expression you
can limit days to 1-31 and months to 1-12.
To recognise the different length of the various maonths requires a
very complex expression. Leap-years are impossible to detect.

Hans Kesting
 
I want to restrict user to select received date  greater then todays date
using RegularExpresionValidator  for this i want regular expression.

I think regular expressions Can not compare data... however they
enforce to be in cetrain format...

Cor:
Correct me if I am wrong...

-Cnu
 
Duggi.

DateTime.Ticks.ToString() gives a string.
So it does not look impossible to compare that with Regex,

However, probably a little bit overdone,

Cor


"Duggi" <[email protected]> schreef in bericht
I want to restrict user to select received date greater then todays date
using RegularExpresionValidator for this i want regular expression.

I think regular expressions Can not compare data... however they
enforce to be in cetrain format...

Cor:
Correct me if I am wrong...

-Cnu
 
Cor Ligthert [MVP] submitted this idea :
Duggi.

DateTime.Ticks.ToString() gives a string.
So it does not look impossible to compare that with Regex,

However, probably a little bit overdone,

Cor

You still can't write a regex to test if a date (whether specified as
dd-MM-yyyy, MM/dd/yyyy or yyyy/MM/dd) is later than some other date
(specified in the same syntax or as a 18+ digit number - the result of
Ticks.ToString())

Hans Kesting
 
Hans,

ticks are just a long giving the ticks after 01-01-01 (in any time format)

At that time it was 1 a 10000000th of milliseconds later this was 2.

Therefore 2 was latter then 1.

Cor
 
Cor Ligthert[MVP] wrote :
Hans,

ticks are just a long giving the ticks after 01-01-01 (in any time format)

At that time it was 1 a 10000000th of milliseconds later this was 2.

Therefore 2 was latter then 1.

Cor

Cor,

That is true. But the original question was "how to write a regex to
validate that a date is *after today*". So how would you do that if the
user had typed in "29-9-2008"?

Hans Kesting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top