Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 957
oz. Avatar asked May 06 '11 14:05

oz.


1 Answers

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

like image 158
Priyank Avatar answered Sep 21 '22 08:09

Priyank