You cannot put the groups option into the .addClassRules() method.
The groups option is something you can only put inside of the .validate() method. You must reference the fields by their name attributes.
$('#myform').validate({
// other options,
groups: {
myGroup: "field1name field2name field3"
}
});
However, if you have a large number of fields, or in your case, the name is dynamically generated, you can construct the list of names external to .validate() and simply use a variable in place of the list.
var names = ""; // create empty string
$('.group_input').each(function() { // grab each input starting w/ the class
names += $(this).attr('name') + " "; // append each name + single space to string
});
names = $.trim(names); // remove the empty space from the end
$('#myform').validate({
// other options,
groups: {
myGroup: names // reference the string
}
});
Working DEMO: http://jsfiddle.net/e99rycac/
Source: https://stackoverflow.com/a/28029469/594235