ASP. NET validation Control CompareValidator

Source: Internet
Author: User

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"> &nbsp;</td> -</tr> +</table> -</div> +</form>
View Code

ASP. NET validation Control CompareValidator

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.