Compare Validator Control
-
Hi, I have 2 textboxes one is txtStartTime and the other is txtEndtime. Compare Validator is not Working for these 2 textboxes.I am storing DateTime values in both the textboxes. I want to check if EndTime is Greater then StartTime.If StartTime is Greater then Endtime then It should give an error message saying StartTime cannot be greater then EndTime. Plz suggest me how to do it. thanks, riz
-
Hi, I have 2 textboxes one is txtStartTime and the other is txtEndtime. Compare Validator is not Working for these 2 textboxes.I am storing DateTime values in both the textboxes. I want to check if EndTime is Greater then StartTime.If StartTime is Greater then Endtime then It should give an error message saying StartTime cannot be greater then EndTime. Plz suggest me how to do it. thanks, riz
use a compare validator to validate two dates. add one comparevalidator on properties select controltocompare,controltovalidate and value to compare. give value as >, < and change the type property into date this wil fulfil ur requirement, if any error let me know coolsweety
-
Hi, I have 2 textboxes one is txtStartTime and the other is txtEndtime. Compare Validator is not Working for these 2 textboxes.I am storing DateTime values in both the textboxes. I want to check if EndTime is Greater then StartTime.If StartTime is Greater then Endtime then It should give an error message saying StartTime cannot be greater then EndTime. Plz suggest me how to do it. thanks, riz
I think you would also want to check that valid dates have been entered. Does this help?
<% @Page Language="C#" %>
<html>
<head>
<title>Validating Dates</title>
</head><body>
<form runat="server">Start: <asp:TextBox id="txtStartDate" runat="server" /> <br /> End: <asp:TextBox id="txtEndDate" runat="server" /> <br /> <asp:CompareValidator id="valid1" runat="server" ControlToValidate="txtStartDate" Type="Date" Operator="DataTypeCheck" Text="The start date must be a valid date." /> <asp:CompareValidator id="valid2" runat="server" ControlToValidate="txtEndDate" Type="Date" Operator="DataTypeCheck" Text="The end date must be a valid date." /> <asp:CompareValidator id="valid3" runat="server" ControlToValidate="txtStartDate" ControlToCompare = "txtEndDate" Type="Date" Operator="LessThanEqual" Text="The start date must be less than or equal to the end date" /> <br /> <br /> <asp:Button runat="server" text="Submit" /> </form>
</body>
</html>