开发者

compare validation attribute inASP.NET MVC3 not working

I am using Model validation in ASP.NET MVC3. The compare emails validation is not firing at all. I installed DataAnnoatations Extensions for MVC3 also. Below is my code.

[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.V开发者_JAVA百科iews.Account.Local.Create), 
    ErrorMessageResourceName = "regxEMail2")]

public string EMail2 { get; set; }


If the validation occurs correctly on the server side then please look at the scripts you have included at the client side as they may be incompatible with the compare validator. In particular, check the versions of jQuery itself and the jQuery.Validate plugin (assuming you are using the most used client-side scripts).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜