How to validate email address in ASP.NET MVC model

Sheonarayan
Posted by Sheonarayan under ASP.NET MVC category on | Points: 40 | Views : 2226
To validate email address in ASP.NET MVC model, use DataType attribute.

        [Required]
[Display(Name = "Your email id")]
[DataType(DataType.EmailAddress)]
public string From { get; set; }


The namespace to be used is System.ComponentModel.DataAnnotations

Hope this helps.

Comments or Responses

Login to post response