mvc [DataType(DataType.EmailAddress) no validation

You could use the usual DataAnnotations library by just using [EmailAddress]

using System.ComponentModel.DataAnnotations;
    [Required]
    [EmailAddress]
    public String Email { get; set; }

Also just for reference, here’s the regular expression version of this validation:

    [RegularExpression(@"^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-‌​]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$", ErrorMessage = "Email is not valid")]
    public String Email {get; set;}

Best of luck!

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)