Q: compare validator for date

G

Guest

Hello,

I put a compare validator in to my applications and set the type as Date. It
works for “MM/dd/yyyy†but not for “MM/dd/yyyy hh:mm:ssâ€. How can I validate
time part too?

Thanks,
 
P

Peter Blum

None of the built in validators handle time. When you use Type=Date, it only
means date.

You have several choices:
1. Create a custom validator that will handle the format you want.
2. I recommend splitting the date and time into two textboxes. This will
help the user in several ways:
- You can use a DatePicker with popup calendar for the date. There are many
available
- There are many separate time entry controls.
- You can assign a validator to individual textboxes and just validate the
format of a single data element. (With Date+Time, you have two elements that
may be incorrect. Users appreciate error messages that are specific.)

I created one of the available datepickers and time textboxes with my
Peter's Date Package (http://www.peterblum.com/datecontrols/home.aspx). You
can see a demo of date + time working together here:
http://www.peterblum.com/DateControls/TimeMain.aspx#Demo (see "Demo 5").
My two controls are actually connected so that you assign one DateTime
object and puts the parts into the individual controls.
In addition, I've included validators for date and time.

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

Guest

I have never used CustomValidator, is there any example to show me what
exactly I should do?
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top