The code below checks dates in 2 textboxes. If you want to campare input
that is scatered over gui elements try to concatenate them and copy them
in hidden fields and compare with them.
I haven't done this and leave it as an exercice :)
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Val.aspx.cs" Inherits="Val"
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="TextBox1"
ControlToValidate="TextBox2" ErrorMessage="Date 2 must be after
Date 1" Operator="GreaterThan"
Type="Date"></asp:CompareValidator>
<br />
<asp:Button ID="Button1" runat="server" Text="Button" /></div>
</form>
</body>
</html>
Let me know if you have any more questions...
Cheers,
Tom Pester
I need to validate 4 fields on ASP.NET web page
Starting Date / / Starting Time : Ending Date
/ / Ending Time :
Staring Date + StartingTime can not be later then Ending Date + Ending
Time
(the starting and ending Times are dropdown boxes)
How would I validate these two values with Validator Controls?
Thanks
Peter