0
我在ASP.NET MVC3中使用了模型验证。比较电子邮件验证完全没有触发。我也为MVC3安装了DataAnnoatations扩展。以下是我的代码。比较ASP.NET MVC3中的验证属性不起作用
[Display(ResourceType = typeof(Resources.Views.Account.Local.Create), Name = "EMail1")]
[Required(ErrorMessageResourceType = typeof(Resources.Views.Account.Local.Create),
ErrorMessageResourceName = "rqEMail1")]
[RegularExpression(@"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*",
ErrorMessageResourceType = typeof(Resources.Views.Account.Local.Create),
ErrorMessageResourceName = "regxEMail1")]
public string EMail1 { get; set; }
[Required]
[Compare("EMail1", ErrorMessageResourceType = typeof(Resources.Views.Account.Local.Create),
ErrorMessageResourceName = "cmpEmail")]
[RegularExpression(@"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*",
ErrorMessageResourceType = typeof(Resources.Views.Account.Local.Create),
ErrorMessageResourceName = "regxEMail2")]
public string EMail2 { get; set; }