There are four distinct parts to creating a fully functional custom validator that works on both the client and the server.
First we subclass Validation Attribute and add our server side validation logic.
Apart from Lable For and Editor For, but we also have Validation Message For.
Validation Attribute class is included in Data Annotations namespace.
Data validation is intended to provide certain well-defined guarantees for fitness, accuracy, and consistency for various kinds of user input into an application. Data Annotations namespace contains various Data Annotation attributes that gives you a simple way to apply different validation rules on model data.
For business applications, data validation can be defined through declarative data integrity rules or procedure-based business rules. These attributes are helpful for common validation requirements like Required, Range, Regular Expression, String Length etc.
When you send a request (GET, POST, and so on) to an ASP.
NET MVC application, the query string, route values and the form collection are passed through model binding classes, which result in usable structures (for example, your action's input parameters).