This article discusses how to validate information you get from users — that is, to make sure that users enter valid information in HTML forms in an ASP. What you'll learn: If you ask users to enter information in a page — for example, into a form — it's important to make sure that the values that they enter are valid.

For example, here's what the page looks like if you forget to enter a course name, if you enter an, and if you enter an invalid date: By default, user input is validated after users submit the page — that is, the validation is performed in server code.

A disadvantage of this approach is that users don't know that they've made an error until after they submit the page.

However, the test will be performed in server code.

You can control how validation errors are displayed by defining CSS classes that have the following reserved names: .

The CSS rules that end in to both have the same fixed size.

That way, the display area for the field is static and won't change the page flow if an error message is displayed.

When you restrict the values that users can enter in forms, you reduce the chance that someone can enter a value that can compromise the security of your site.

To see how validation works, run this page and deliberately make mistakes.

These pairs let you define rules for both conditions: an error condition and a "normal" (non-error) condition.