As discussed in the In Depth section of this chapter, comparison validators let you compare a value in a data-entry control to another value, either in another data-entry control or a constant value.
You can see this comparison validator at work in Figure 18.2 and in the ValidationControls example on the CD-ROM, where the code is checking the value the users have entered for class rank and making sure that it's less than the value they've entered for their class size.
Here, I've set the comparison validator's ControlToValidate property to TextBox2, and its ControlToCompare property to TextBox1. I've also set the Type property to Integer and the Operator property to GreaterThanEqual (see the In Depth section of this chapter for other options on these properties). You also can compare to a constant value—just use the ValueToCompare property. And, as with other validation controls, you set the ControlToValidate property to set the control whose data you want to validate, and place the error message in the ErrorMessage property.
In Figure 18.2, you can see the comparison validator displaying its error message—when the user corrects the situation in one or the other text boxes and the text box loses the focus, the comparison validator will test the data again.