[英]ASP.NET MVC 5 EmailAddress attribute not working properly
I use EmailAddress
attribute. 我使用EmailAddress
属性。 When you type tom@jerry
it accepts as a valid email. 当您键入tom@jerry
它将接受为有效电子邮件。 When I type tom@jerry.
当我键入tom@jerry.
only then it complains. 只有这样,它才抱怨。 How can I solve this problem so the validation complains when given input like tom@jerry
. 我该如何解决此问题,以便在给定输入(例如tom@jerry
时验证tom@jerry
。
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 ASP.NET MVC 5:EmailAddress属性自定义错误消息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.