Solved

Using a Compare validator for Time

Posted on 2011-09-22
2
600 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
2 Comments
 
LVL 15

Accepted Solution

by:
pateljitu earned 500 total points
Comment Utility
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
Comment Utility
Thank You!
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

728 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now