I need the end date to always be greater than the start date, I tried checking with CompareValidator.
The code is as follows:
I have a start date for the text field
<asp:TextBox ID="TxtStartDate"
runat="server" />
<asp:CalendarExtender Enabled="True"
ID="TxtStartDate_CalendarExtender"
TargetControlID="TxtStartDate"
runat="server" />
Another end date for TextBox.
<asp:TextBox ID="TxtEndDate"
runat="server" />
<asp:CalendarExtender Enabled="True"
ID="TxtEndDate_CalendarExtender"
TargetControlID="TxtEndDate"
runat="server" />
<asp:CompareValidator ControlToCompare="TxtStartDate"
ControlToValidate="TxtEndDate"
Display="Dynamic"
ErrorMessage="CompareValidator"
ID="CompareValidator1"
Operator="GreaterThan"
Type="Date"
runat="server" />
But the check for missing the comparison field is skipped.
For example, when the start date is 2/04/2012, and the end date is 10/04/2012, it fires.
source
share