CompareValidator: The
CompareValidator control compares a value in one control with a fixed value,
or, a value in another control.
·
This
control used to compare the value of one input control to the value of another
input control, constants and data type using a comparison operator (equals,
greater than, less than, and so on).
·
If
the input control is empty, the validation will succeed. Use the
RequiredFieldValidator control to make the field required.
Property
|
Description
|
ControlToCompare
|
The name of the control to compare with
|
Operator
|
The type of comparison to perform. The operators are:
|
Type
|
Specifies the data type of the values to compare. The types are:
|
ValueToCompare
|
A specified value to compare with
|
Control usage:
<asp:TextBox runat="server" ID="txtNumber1"></asp:TextBox>
<asp:TextBox runat="server" ID="txtNumber2"></asp:TextBox>
<asp:CompareValidator ID="cmpNumber"
runat="server"
ControlToValidate="txtNumber1" ControlToCompare="txtNumber2"
Type="Integer" ErrorMessage="Number not matched">
</asp:CompareValidator>
|
Comments
Post a Comment