This is a migrated thread and some comments may be shown as answers.

RadDateInput and CompareValidator

4 Answers 121 Views
Input
This is a migrated thread and some comments may be shown as answers.
ADH
Top achievements
Rank 1
ADH asked on 18 Nov 2008, 06:15 PM
Everything I've seen concerning this suggests that this code should validate correctly when your focus leaves RadDateInput2. Instead, valid dates which are later than the initial date produce errors - in fact, any valid date entered in the second box produces a validation error. What am I doing wrong?

<%@ Page Language="C#" AutoEventWireup="true" Codebehind="Test.aspx.cs" Inherits="TestProject.Test" %> 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
   <title>Untitled Page</title> 
</head> 
<body> 
   <form id="form1" runat="server"
      <div> 
         <telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> 
         Date 1: 
         <telerik:RadDateInput ID="RadDateInput1" runat="server" SelectedDate="09/19/2008" /> 
         <br /> 
         <br /> 
         Date 2: 
         <telerik:RadDateInput ID="RadDateInput2" runat="server" /> 
         <br /> 
         <asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="Date 2 must be greater than or equal to date 1." 
            ControlToCompare="RadDateInput1" ControlToValidate="RadDateInput2" Type="Date" 
            Operator="GreaterThanEqual" /> 
      </div> 
   </form> 
</body> 
</html> 
 

4 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 18 Nov 2008, 06:29 PM
Hello Ashley,

I suggest you examine our online demo illustrating an appropriate approach.
Date Validation

Let us know if you have additional questions.

Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
ADH
Top achievements
Rank 1
answered on 18 Nov 2008, 06:35 PM
When I change the control from a DatePicker to a DateInput, the CompareValidator again fails to work. We are using DateInputs in our solution currently - is this the only solution, to switch to DatePickers?
0
Accepted
Daniel
Telerik team
answered on 19 Nov 2008, 02:32 PM
Hello Ashley,

Please try to modify your CompareValidator as follows:
<asp:CompareValidator  
  ID="dateCompareValidator"  
  runat="server"  
  ControlToValidate="RadDateInput2" 
  ControlToCompare="RadDateInput1"  
  Operator="GreaterThan"  
  ErrorMessage="The second date must be after the first one."
</asp:CompareValidator> 

I hope this helps.

Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
ADH
Top achievements
Rank 1
answered on 19 Nov 2008, 03:04 PM
Bingo - apparently the type attribute covered something else entirely - DataTypeCheck value, I suppose. Thank you!
Tags
Input
Asked by
ADH
Top achievements
Rank 1
Answers by
Daniel
Telerik team
ADH
Top achievements
Rank 1
Share this question
or