By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,299 Members | 1,175 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,299 IT Pros & Developers. It's quick & easy.

Q: validation expression

P: n/a
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.
Nov 19 '05 #1
Share this Question
Share on Google+
5 Replies

P: n/a
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." wrote:
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.

Nov 19 '05 #2

P: n/a
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" wrote:
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." wrote:
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.

Nov 19 '05 #3

P: n/a
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: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:75**********************************@microsof t.com...
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" wrote:
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." wrote:
> 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.
>
>

Nov 19 '05 #4

P: n/a
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" wrote:
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: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:75**********************************@microsof t.com...
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" wrote:
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." wrote:

> 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.
>
>


Nov 19 '05 #5

P: n/a
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: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:32**********************************@microsof t.com...
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" wrote:
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: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:75**********************************@microsof t.com...
> 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" wrote:
>
>> 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." wrote:
>>
>> > 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.
>> >
>> >


Nov 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.