The CompareValidator control enables you to perform a data type check, like we need to make sure the data a user enters in two fields on an input form is the same, such as when performing password or email verification.
The CompareValidator has six important properties:
ControlToValidate : The ID of the form field being validated.
Text : The error message displayed when validation fails.
Type : The type of value being compared. Possible values are String, Integer, Double, Date, and Currency.
Operator The type of comparison to perform. Possible values are DataTypeCheck, Equal, GreaterThan, GreaterThanEqual, LessThan, LessThanEqual, and NotEqual.
ValueToCompare : The fixed value against which to compare.
ControlToCompare : The ID of a control against which to compare
Code Example :
< asp:TextBox ID="txtPasswd1" runat="server" TextMode="Password" >< /asp:TextBox >< br />
< br />
< asp:Label ID="Label6" runat="server" Text="Re-enter Password" Width="136px" >< /asp:Label >< br / >
< asp:TextBox ID="txtPasswd2" runat="server" TextMode="Password" >< /asp:TextBox >
< asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="Password not match" ControlToCompare="txtPasswd1" ControlToValidate="txtPasswd2" Display="Dynamic" >< /asp:CompareValidator >
No comments:
Post a Comment