Site icon Dotnet Helpers

Validation in MVC4 Razor with the Data Annotation Validators in “MODEL”

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:

Below output shows the Email validation and Range validation

NOTE :

Validation for password comparsion

Exit mobile version