MVC [数据类型(DataType.EmailAddress)没有验证 [英] mvc [DataType(DataType.EmailAddress) no validation
问题描述
我使用一个电子邮件字段与此code:
I'm using this code on an email field:
[Required]
[DataType(DataType.EmailAddress)]
[Display(Name = "Email address")]
public string Email { get; set; }
[数据类型(DataType.EmailAddress)]
不起作用(验证不会发生在任何一台服务器没有在客户端)。
[DataType(DataType.EmailAddress)]
does not work (validation does not occur no at a server not on the client side).
我不知道我是否应该实现自己的自定义属性或者我可以使用附带的MVC 3。
I am not sure if I should implement myself a Custom Attribute or I can use one included with MVC 3.
可否请你建议我一个解决方案的情况下,创建自定义属性,我需要。
Could you please suggest me a solution for creating a custom attribute in case I need to.
我也看了一些额外的扩展,例如
http://nuget.org/packages/DataAnnotationsExtensions.MVC3
I read also about some additional extensions, example http://nuget.org/packages/DataAnnotationsExtensions.MVC3
你会建议给我吗?
推荐答案
目前我使用解决我的问题
http://dataannotationsextensions.org
At the moment I solved my problem using http://dataannotationsextensions.org
它只是工作,你加他们的库的NuGet
it just work, you add their library with NuGet
using DataAnnotationsExtensions;
[Required]
[DataType(DataType.EmailAddress)]
[Email]
public string Email { get; set; }
这篇关于MVC [数据类型(DataType.EmailAddress)没有验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!