Tural Asgarov
Tural Asgarov

Reputation: 1377

ASP.NET MVC 5 EmailAddress attribute not working properly

I use EmailAddress attribute. When you type tom@jerry it accepts as a valid email. When I type tom@jerry. only then it complains. How can I solve this problem so the validation complains when given input like tom@jerry.

Upvotes: 1

Views: 2174

Answers (1)

Ikram Shah
Ikram Shah

Reputation: 1246

You can implement regular expression on top of it like this one is for white spaces

[RegularExpression(@"^\S*$", ErrorMessage = "Email Address cannot have white spaces")]

Here is the link for similar problem

ASP.NET MVC 5: EmailAddress attribute custom error message

Upvotes: 3

Related Questions