CompareValidator
the function is to compare the values entered by the two input boxes in a consistent way, commonly used as a validation input password and confirm the password of the business.
properties |
description |
operator |
comparison operator, selectable values datatypecheck, Equal, GreaterThan, Greaterthanequl, LessThan, Lessthanequal, NotEqual |
valuetocompare " |
The value to the right of the operator being compared |
|
settings compared to another control |
data type optional string integer Double date , currency |
ControlToValidate (left of symbol) ControlToCompare the control to be compared (right of the symbol) operator comparison Operation Type property
1<form id="Form1"runat="Server">2<div>3<table border="1">4<tr>5<tdclass="Style1">Password</td>6<tdclass="Style2">7<asp:textbox id="txtpwd"runat="Server"Textmode="Password"></asp:TextBox>8</td>9</tr>Ten<tr> One<tdclass="Style1">confirm password</td> A<tdclass="Style2"> -<asp:textbox id="txtconfirmpwd"runat="Server"Textmode="Password"></asp:TextBox> -<asp:comparevalidator id="CompareValidator1"runat="Server" theControltocompare="txtpwd"Controltovalidate="txtconfirmpwd" -Errormessage="*password not match"Forecolor="Red"></asp:CompareValidator> -</td> -</tr> +</table> -<asp:button id="btnsubmit"runat="Server"text="Submit"/> +</div> A</form>
View Code
compare with a fixed valueValueToCompare operator Compare operations type properties
1<form id="Form1"runat="Server">2<div>3<table border="1">4<tr>5<tdclass="Style3">input value </td>6<tdclass="Style4">7<asp:textbox id="Txtvalue"runat="Server"Textmode=" Number"></asp:TextBox>8<asp:comparevalidator id="CompareValidator1"runat="Server" 9Controltovalidate="Txtvalue"Errormessage="* number is not greater than" TenForecolor="Red"Operator="GreaterThan"Type="Integer"Valuetocompare=" -"></asp:CompareValidator> One</td> A</tr> -<tr> -<tdclass="Style1"> the<asp:button id="btnsubmit"runat="Server"text="Submit"/> -</td> -<tdclass="Style2"> </td> -</tr> +</table> -</div> +</form>
View Code
ASP. NET validation Control CompareValidator