Solved

Using a Compare validator for Time

Posted on 2011-09-22
2
633 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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

813 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

10 Experts available now in Live!

Get 1:1 Help Now