Using Data Annotations to validate fields in an HTML page and Web API


Someone has an example of how to create a field validation on an HTML page using Data Annotation, Web API and C #.

In MVC with you, this is easily accomplished by using Wizard when creating a View.

asked by anonymous 16.12.2014 / 19:51

1 answer


First the DataAnnotation are the properties that stay on top of the fields of your model


[Display(Name = "User name")]
[EmailAddress(ErrorMessage = "E-mail em formato inválido.")]

A simple and straightforward article: link

16.12.2014 / 20:22