[Required] [DataType(DataType.EmailAddress)] [Display(Name = "Email address")] [RegularExpression(@"^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$",ErrorMessage="Invalid email address")] public string Email { get; set; }
Friday, January 18, 2013
How to validate an email address by Model DataAnnotations in ASP.NET MVC
What is the best regular expression for an email address?
^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$
??
http://fightingforalostcause.net/misc/2006/compare-email-regex.php
??
http://fightingforalostcause.net/misc/2006/compare-email-regex.php
Subscribe to:
Posts (Atom)