How to count the children (elements) inside a fieldgroup?
If you use the following code you will see the value that you need.

/**
 * Implements hook_form_alter().
 */
function YOUR_MODULE_form_alter(&amp;$form, &amp;$form_state, $form_id) {      
   //you need the devel module to use dpm() function
  //My field group name is group_g2
  dpm(count($form['#groups']['group_g2']-&gt;children));
}


Is easy to track values if you use the Devel and Search Krumo modules