计算具有组名的多个选中框

I have a form with several different groups of checkboxes and i need to require a minimum number checked in each group. I have a working code validation for 1 group, but it needs to include other checkbox group names.

This works but for only one checkbox group:

if(count($_POST['form']['checkgroup1']) <= 2)
$invalid[] = RSFormProHelper::getComponentId("checkgroup1");

This fails but maybe you can see what i'm going for:

if(count($_POST['form']['checkgroup1']) + ($_POST['form']['checkgroup2']) <= 1)
$invalid[] = RSFormProHelper::getComponentId("checkgroup1");

Thanks for any help.

It seems to be an error in your if condition,

if((count($_POST['form']['checkgroup1']) + count($_POST['form']['checkgroup2'])) <= 1)
{
   $invalid[] = RSFormProHelper::getComponentId("checkgroup1");
}

please check it once. hope it will help.