Solved

Using a Compare validator for Time

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

738 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