Q: validation expression

G

Guest

Hello,
I have this validation expression:

^(?:(?:0?[13578]|1[02])|(?:0?[469]|11)(?!\/31)|(?:0?2)(?:(?!\/3[01]|\/29\/(?:(?:0[^48]|[13579][^26]|[2468][^048])00|(?:\d{2}(?:0[^48]|[13579][^26]|[2468][^048]))))))\/(?:0?[1-9]|[12][0-9]|3[01])\/\d{4}$

This is supposed to match MM/DD/YYYY it is working in all computer except
one in our office. What is problem?
Thanks,
Jim.
 
G

Guest

Hi,
r u getting problem with this expression only or any of your validators are
not
working? If you are getting this problem for all validators then you need
to upgrage your service pack to recent one.

regards,
satish
 
G

Guest

Validator in asp.net applications works to match 02/02/2005 and does not give
me problem to submit my data on the screen. However when I go to this one
computer and type the same date on the same field I see validator error
message assuming 02/02/2005 is not right format. I know this date is not the
reason for error in other computers.



i9arcanes said:
Hi,
r u getting problem with this expression only or any of your validators are
not
working? If you are getting this problem for all validators then you need
to upgrage your service pack to recent one.

regards,
satish


JIM.H. said:
Hello,
I have this validation expression:

^(?:(?:0?[13578]|1[02])|(?:0?[469]|11)(?!\/31)|(?:0?2)(?:(?!\/3[01]|\/29\/(?:(?:0[^48]|[13579][^26]|[2468][^048])00|(?:\d{2}(?:0[^48]|[13579][^26]|[2468][^048]))))))\/(?:0?[1-9]|[12][0-9]|3[01])\/\d{4}$

This is supposed to match MM/DD/YYYY it is working in all computer except
one in our office. What is problem?
Thanks,
Jim.
 
P

Peter Blum

Hi Jim,

You have run into a common problem for ASP.NET users: everyone misses the
fact that the CompareValidator handles date validation. In fact, it actually
determines if you have a real, legal date. Just set its
Operator=DataTypeCheck and Type=Date.

It follows the CultureInfo object of the current thread to get the
ShortDatePattern ("MM/dd/yyyy"). If it has the wrong one, see the <@ Page
Culture=> property to set up the desired cultureInfo object.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

JIM.H. said:
Validator in asp.net applications works to match 02/02/2005 and does not
give
me problem to submit my data on the screen. However when I go to this one
computer and type the same date on the same field I see validator error
message assuming 02/02/2005 is not right format. I know this date is not
the
reason for error in other computers.



i9arcanes said:
Hi,
r u getting problem with this expression only or any of your validators
are
not
working? If you are getting this problem for all validators then you
need
to upgrage your service pack to recent one.

regards,
satish


JIM.H. said:
Hello,
I have this validation expression:

^(?:(?:0?[13578]|1[02])|(?:0?[469]|11)(?!\/31)|(?:0?2)(?:(?!\/3[01]|\/29\/(?:(?:0[^48]|[13579][^26]|[2468][^048])00|(?:\d{2}(?:0[^48]|[13579][^26]|[2468][^048]))))))\/(?:0?[1-9]|[12][0-9]|3[01])\/\d{4}$

This is supposed to match MM/DD/YYYY it is working in all computer
except
one in our office. What is problem?
Thanks,
Jim.
 
G

Guest

Peter, thank for the reply. I did not know that I would validate only
MM/dd/yyyy format with date validator. I am new in asp.net. Now, my
applications have many regular expression validator in many applications. If
it is cultural setting issue, is there anything I can do in the control panel
to get regular expression working. We have more than 20 computers, I still do
not understand why only one computer is the problem.
Peter Blum said:
Hi Jim,

You have run into a common problem for ASP.NET users: everyone misses the
fact that the CompareValidator handles date validation. In fact, it actually
determines if you have a real, legal date. Just set its
Operator=DataTypeCheck and Type=Date.

It follows the CultureInfo object of the current thread to get the
ShortDatePattern ("MM/dd/yyyy"). If it has the wrong one, see the <@ Page
Culture=> property to set up the desired cultureInfo object.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

JIM.H. said:
Validator in asp.net applications works to match 02/02/2005 and does not
give
me problem to submit my data on the screen. However when I go to this one
computer and type the same date on the same field I see validator error
message assuming 02/02/2005 is not right format. I know this date is not
the
reason for error in other computers.



i9arcanes said:
Hi,
r u getting problem with this expression only or any of your validators
are
not
working? If you are getting this problem for all validators then you
need
to upgrage your service pack to recent one.

regards,
satish


:

Hello,
I have this validation expression:

^(?:(?:0?[13578]|1[02])|(?:0?[469]|11)(?!\/31)|(?:0?2)(?:(?!\/3[01]|\/29\/(?:(?:0[^48]|[13579][^26]|[2468][^048])00|(?:\d{2}(?:0[^48]|[13579][^26]|[2468][^048]))))))\/(?:0?[1-9]|[12][0-9]|3[01])\/\d{4}$

This is supposed to match MM/DD/YYYY it is working in all computer
except
one in our office. What is problem?
Thanks,
Jim.
 
P

Peter Blum

Hi Jim,

Indeed you sound like you are inexperienced.

Regular expressions are not culture sensitive. Regular expressions are a
concept that matches a string to a pattern.
With dates, you are trying to match a string to a date value. A date value,
as you know, has rules for numeric ranges on each "part". While a regular
expression can detect a value date pattern, it really cannot tell that the
month is February and the day is 31.

As you explore .net, you will start using their DateTime object to manage
dates. It is a fantastic class with a rich set of properties and methods. It
can determine that a date is illegal. It has Parse() methods to convert
strings to dates or throw exceptions if the date is illegal.

The CompareValidator uses the DateTime object to do this. It uses a similar
JavaScript Date object on the client-side. That's why you should simply use
the CompareValidator.

The DateTime object converts strings to dates following the CultureInfo
object of the current thread. I've told you to use the <@ Page Culture=> tag
to define the culture you like. That is embedded on the page so as it
migrates to different servers, they will all use the same rules.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

JIM.H. said:
Peter, thank for the reply. I did not know that I would validate only
MM/dd/yyyy format with date validator. I am new in asp.net. Now, my
applications have many regular expression validator in many applications.
If
it is cultural setting issue, is there anything I can do in the control
panel
to get regular expression working. We have more than 20 computers, I still
do
not understand why only one computer is the problem.
Peter Blum said:
Hi Jim,

You have run into a common problem for ASP.NET users: everyone misses the
fact that the CompareValidator handles date validation. In fact, it
actually
determines if you have a real, legal date. Just set its
Operator=DataTypeCheck and Type=Date.

It follows the CultureInfo object of the current thread to get the
ShortDatePattern ("MM/dd/yyyy"). If it has the wrong one, see the <@ Page
Culture=> property to set up the desired cultureInfo object.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

JIM.H. said:
Validator in asp.net applications works to match 02/02/2005 and does
not
give
me problem to submit my data on the screen. However when I go to this
one
computer and type the same date on the same field I see validator error
message assuming 02/02/2005 is not right format. I know this date is
not
the
reason for error in other computers.



:

Hi,
r u getting problem with this expression only or any of your
validators
are
not
working? If you are getting this problem for all validators then you
need
to upgrage your service pack to recent one.

regards,
satish


:

Hello,
I have this validation expression:

^(?:(?:0?[13578]|1[02])|(?:0?[469]|11)(?!\/31)|(?:0?2)(?:(?!\/3[01]|\/29\/(?:(?:0[^48]|[13579][^26]|[2468][^048])00|(?:\d{2}(?:0[^48]|[13579][^26]|[2468][^048]))))))\/(?:0?[1-9]|[12][0-9]|3[01])\/\d{4}$

This is supposed to match MM/DD/YYYY it is working in all computer
except
one in our office. What is problem?
Thanks,
Jim.
 

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

Top