We can add validation controls to our form that will check the information input by the user. If they input an incorrect value, then an error message will be displayed.
There are several different types of validation controls. Each performs a specific type of validation when the form is updated.
We will add a RangeValidator to our form to check that the birthday we have selected is credible:
Right-click on the validation control and select Properties from the shortcut menu.
Set the ControlToValidate to txtBirthday.
Change the Type from String to Date.
Set the MinimumValue to 1/1/1880.
Set the MaximumValue to 1/1/2009.
Set the ErrorMessage to Please select a credible birthday.
If we return to our birthday page in our web browser, we see that if we enter a spurious date such as 1/1/1850
and then press Enter to cause a postback, the validation kicks in and we are greeted with an error message.