These pairs let you define rules for both conditions: an error condition and a "normal" (non-error) condition.
It's important to understand that the markup for the error display is always rendered, even if there are no errors.
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.The following example shows a page that illustrates these steps. code-cshtml Main] To see how validation works, run this page and deliberately make mistakes.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.Performing validation in server code is a security measure, in case users bypass client-based validation.
The following page shows how to add client validation features to the example shown earlier. code-cshtml Main] Not all validation checks run on the client.
A disadvantage of this approach is that users don't know that they've made an error until after they submit the page.