Data Annotation

Data validation play major role when developing web application. In Asp.net MVC, we can easily implement validation to application by using Data Annotation attribute to model. Data Annotation attribute classes are present in System.ComponentModel. DataAnnotations namespace. It is a common validation attributes which extend the built-in ASP.NET DataAnnotations (Required, Range, RegularExpression, StringLength etc.,). ASP.NET MVC uses jquery unobtrusive validation to perform client side validation.

MODEL

View

OUTPUT:

Validation using Data Annotation Validator 1 - MVC - dotnet-helpers

Below output shows the Email validation and Range validation

Validation using Data Annotation Validator 2 - MVC - dotnet-helpers

NOTE :

Validation for password comparsion