Adding a group using unobtrusive jQuery validation

I am using asp.net mvc 3 and I have a script similar to the script in this jQuery post Check multiple fields with one error . I am using IClientValidatable since I had to create a special validator for my script. But if I apply the validator to each of the properties, I will get an error message 3 times. Therefore, I know that you can use groups to tell the validator to group messages for several fields, and I could not find an option to do this with C #, so I tried to do something like this:

$("#frmUser").validate({ groups: { DateofBirth : "Year Month Day" } }); 

but the whole check stops working, so I feel like a line of code overrides all unobtrusive codes. Therefore, I am wondering if there is a way to set groups in the validator.unobtrusive.adapters.add or validator.addMethod methods. Thanks

+7
source share
2 answers

Something like this might help: MVC3 an unobtrusive group of input validation

+1
source

Have you tried:

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

0
source

All Articles