Compare Validator to check mm/dd/yyyy

C

Cam

Hello,

I have a compare validator control in my vb.net project. I have the TYPE
set to date, the CONTROLTOVALIDATE set to the textbox, and the OPERATOR set
to datatypecheck. I want the date only as mm/dd/yyyy (not mm/dd/yy). What
is the best way to do this? Can I do it with the controls properties or
must
I do it in code? Thanks in advance.

Cam
 
S

Steven Cheng[MSFT]

Hi Cam,

As for your problem on validating a certain DateTime input value. I agree
with DujHoD that the RegularExpressionValidator or CustomValidator may be
more suitable for you.
#CustomValidator Control
http://msdn.microsoft.com/library/en-us/cpgenref/html/cpconCustomValidatorCo
ntrol.asp?frame=true

#RegularExpressionValidator Control
http://msdn.microsoft.com/library/en-us/cpgenref/html/cpconRegularExpression
ValidatorControl.asp?frame=true

The CompareValidtor is used to compare two values or with another control's
value. To valiating DateTime input with a specified format(such as
mm/dd/yyyy... ) , its better to use regex. And here are some further
resources on Regex with Date/Time validation:

#RegEx Short Date Validation
http://www.eggheadcafe.com/PrintSearchContent.asp?LINKID=474

http://www.regexlib.com/DisplayPatterns.aspx

Hope also helps. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
C

Cam

Thanks, looks like I was using the wrong control. The links were helpful, I
just have to learn to think about formating dates differently then i am use
to (vb 6.0)

Cam
 

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top