We will start with the Required built-in validation which allows validators to check whether the field has a value or not. The required validation is necessary to ensure that the mandatory fields are filled in or updated by the user before transmitting the data to the server for further processing.
The following steps will help us in understanding how validation works:
-
The Required field validator is added using data annotation in the model.
- The MVC engine performs validation on both client-side and server-side using this configuration.
-
When MVC engine generates the form view with the input field, it also scaffolds the <span> element along with each input field to hold error messages.
-
When we run the application ...