COMPARE VALIDATOR
First - Add New - Web Form - and Select Button & Labels & TextBoxs From ToolBox.
Select - Compare Validation Control From Validation Tool
Next - Select Compare Validation Click F4 Property Window for Password Control to Validate = txtPassword & Control to Compare =txtConfirmPassword Error Message empty
Next - Select Compare Validation Press - F4 Property Window for Confirm Password Control to Validate =txtConfirmPassword & Control to Compare =txtPassword Error Message Given to Required
Next - F5 Click - Run the Form - Button Enter the Password Incorrect Show the Error Message below like that
Now Enter the Correct Password Hide the Error Message
The CompareValidator control compares a value in one control with a fixed value, or, a value in another control.
CompareValidator control compare user inputted value with the another input control value or a constant value.
DEMO
DEMO
Html Coding
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr><td>
<asp:Label ID="Label1" runat="server" Text="Password"></asp:Label>
</td><td>
<asp:TextBox ID="txtPassword" runat="server"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator1"
runat="server" ControlToCompare="txtConfirmPassword" ControlToValidate="txtPassword"></asp:CompareValidator>
</td></tr>
<tr><td>
<asp:Label ID="Label2" runat="server" Text="Confirm Password"></asp:Label>
</td><td>
<asp:TextBox ID="txtConfirmPassword" runat="server"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator2"
runat="server" ControlToCompare="txtPassword"
ControlToValidate="txtConfirmPassword" ErrorMessage="Password Not Same"></asp:CompareValidator>
</td></tr>
<tr><td colspan ="2">
<asp:Button ID="Button1" runat="server" Text="Save" />
</td></tr>
</table>
</div>
</form>
</body>
</html>
comparevalidator validation success if inputted value matches the criteria specified by the Operator, ValueToCompare or ControlToCompare property.
properties:
Properties | Description |
---|---|
Type | it specifies the data type |
ControlToCompare | it specifies the value of the input control to compare with |
ValueToCompare | it specifies the constant value to compare with |
Operator | it specifies the comparison operator, the available values are: Equal, NotEqual, GreaterThan, GreaterThanEqual, LessThan, LessThanEqual and DataTypeCheck |
First - Add New - Web Form - and Select Button & Labels & TextBoxs From ToolBox.
Select - Compare Validation Control From Validation Tool
Next - Select Compare Validation Click F4 Property Window for Password Control to Validate = txtPassword & Control to Compare =txtConfirmPassword Error Message empty
Next - Select Compare Validation Press - F4 Property Window for Confirm Password Control to Validate =txtConfirmPassword & Control to Compare =txtPassword Error Message Given to Required
Html Code For Compare Validation
Next - F5 Click - Run the Form - Button Enter the Password Incorrect Show the Error Message below like that
Now Enter the Correct Password Hide the Error Message
0 comments:
Post a Comment