Tuesday, 20 December 2016

Data annotation validation for email ID in C#

//For all kind of emails it can validate like example.123@example.com, .com.in,.co.in etc

[RegularExpression("^$|^[a-z0-9_\\+-]+(\\.[a-z0-9_\\+-]+)*@[a-z0-9-]+(\\.[a-z0-9]+‌​)*\\.([a-z]{2,})(\\.([a-z]{2,4}))?$", ErrorMessage = "The email field is not a valid e-mail address.")]

No comments:

Post a Comment