开发者

Adding a group using jQuery unobtrusive validation

I'm using asp.net mvc 3, and I have a scenario like the one in this post JQuery Validate multiple fields with one error. I'm using the IClientValidatable since I had to create a custom validator for my scenario. But if I apply the validator to each of the properties, I will get 3 times the error message. So I know you can use groups to tell the validator to group messages for multiple fields, and I couldn't find an option to do it from C#, so I tried to do something like this:

$("#frmUser").validate({
    groups: {
        DateofBirth : "Year 开发者_如何学运维Month Day"
    }
});

but the whole validation stops working, so I have the feeling that line of code overrides whatever the unobtrusive code generates. So I'm wondering if there's a way to set groups in the

validator.unobtrusive.adapters.add or validator.addMethod methods. Thanks


Something like this could help: MVC3 unobtrusive validation group of inputs


Have you already tried :

$.validator.setDefaults({ groups: { DateofBirth : "Year Month Day" } });

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜