ASP.NET CompareValidator is very useful when need to check two string are equal or not. CompareValidator is useful in compare in confirm password validation. The CompareValidator control belongs to System.Web.UI.WebControls
Syntax
Property | Description |
---|---|
ControlToValidate | Specifies control name which needs to be validate. |
Display | Specifies behavior of the error message. |
EnableClientScript | Specifies whether or not client-side validation is enabled. |
Enabled | Specifies whether or not validation control is enabled or not. |
ErrorMessage | Specifies error messageto be display in validation summary. |
ForeColor | Specifies error message color. |
IsValid | Indicate if associate control passes validation or not. |
SetFocusOnError | Set focus on associate control if validation fails. |
Text | Specifies text to be display if validation fails. |
ValidationGroup | Specifies validation group name. |
Validate | Update the isvalid propery. |
ValidateGetValidationProperty | Determineing validation property of a control, if it exists. |
Equal | This is used to check whether the compared value are equal. |
NotEqual | This is used to check whether the compared value are not equal. |
GreaterThan | This is used to check whether the compared value are greater than. |
GreaterThanEqual | This is used to check whether the compared value are greater than equal |
LessThan | This is used to check whether the compared value are less than. |
LessThanEqual | This is used to check whether the compared value are less than equal. |
DataTypeCheck | This is used to compare data type. |
Above example will produce following output