Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using a Compare validator for Time

Posted on 2011-09-22
2
Medium Priority
?
753 Views
Last Modified: 2012-05-12
I have two dropdowns on a form.  One for the start time and one for the end time.  Before submitting the form I'd like to insure that the end time is not less than the start time.

So, if the user does this

Start Time: 12:00 PM
End Time: 11:00 AM

the CompareValidator would fire.  

I can't get the CompareValidator to fire though.  Am I doing something wrong?  Please see code.
<asp:CompareValidator ID="CompareValidator2" runat="server" 
    ErrorMessage="Your End Time cannot be less than you Start Time." 
    ControlToCompare="ddlEndTime" 
    Operator="LessThan" 
    ControlToValidate="ddlStartTime" 
    Text="*" 
    Display="Dynamic">
</asp:CompareValidator>

Open in new window

0
Comment
Question by:cdemott33
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 15

Accepted Solution

by:
pateljitu earned 2000 total points
ID: 36581588
Try using custom validation, please see this article:

http://zubairdotnet.blogspot.com/2008/11/using-customvalidator-to-compare-time.html

Also CompareValidator will handle: String, Integer, Double, Date, currency

http://msdn.microsoft.com/en-us/library/system.web.ui.mobilecontrols.comparevalidator.type.aspx
0
 

Author Closing Comment

by:cdemott33
ID: 36581631
Thank You!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question