I have a compare validator which validates on two <telerik:RadDatePicker>
Start date and End date. The validation rule is simple, Check if Start Date is greater than the End Date and show the error message to the user to correct it
it works as expected but when the start and end dates are the same it is showing the message which is not expected. Code Below:
<asp:CompareValidator ID="dateCompareValidator" runat="server" ControlToValidate="endDate" ControlToCompare="startDate" Operator="GreaterThan" Type="Date" ErrorMessage="Start Date is greater than the End Date - please correct dates."Display="Dynamic"></asp:CompareValidator>
and the date pickers are as follows for both start date and end date:
<telerik:RadDatePicker CssClass="rcCalPopup" ID="endDate" runat="server"
Skin="Vista">
<DateInput ID="DateInput2" runat="server" LabelCssClass="radLabelCss_Vista" Skin="Vista">
</DateInput>
<Calendar ShowRowHeaders="false" ID="Calendar2" runat="server" UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False"
ViewSelectorText="x" Skin="Vista">
</Calendar>
<DatePopupButton CssClass="rcCalPopup"></DatePopupButton>
</telerik:RadDatePicker>
The rule you have defined with the Validator is:
The validator
Operator
property determines the rule for valid input, not invalid input.So if you want to allow equal dates you have to use
GreaterThanEqual
Note that i've also changed the
ErrorMessage
accordingly. If the input control is empty, no validation functions are called and validation succeeds. Use aRequiredFieldValidator
control to require the user to enter data in the input control.