I have a Account Model in which I am using Email Address as Username
public class RegisterModel
{
[Required]
[Display(Name = \"Email Add
DataType
alone will not trigger any server-side validation. But, since MVC 4 using DataType.EmailAddress
will make the HTML input use type="email"
, which in turn makes jQuery Validation perform Regex validation on the client.
.NET 4.5 introduced the [EmailAddress]
attribute, a subclass of DataTypeAttribute
. By using [EmailAddress]
you get both client and server side validation.