I\'m using this code on an email field:
[Required]
[DataType(DataType.EmailAddress)]
[Display(Name = \"Email address\")]
public string Email
As Felix mentioned, the problem is on the View level, you need to use EditorFor() in your View instead of TextBoxFor(), the EditorFor() will render:
which will trigger the validation, while TextBoxFor() will render:
So in order to validate your entered email address, you need (in combination with EditorFor()) to use only:
[DataType(DataType.EmailAddress)]
public string Email { get; set; }
This way, your entered value for email will be always validated, but if you don't enter a value for email, nothing will happen (unless you specified the [Required] attribute), the form will be submitted with an empty email address.