How to make a checkbox field required when a radio button is selected. I need to show a validation error message when a radio button is clicked but none of the checkbox is checked. The checkbox field is optional in content type. Should be required when radio button is clicked. How can it implement this programaticaly. Not interested to add conditional field  module for a single requirement.
In form alter use this code

function my_module_form_alter(&amp;$form, &amp;$form_state, $form_id) {
      $radio = $form['#node']-&gt;field_radio['und'][0]['value'];

      if($radio == 1){//if 
         $form['field_checkbox']['und']['0']['value']['#required'] = TRUE;
         //OR
         $form['field_checkbox']['und']['0']['#required'] = TRUE;
      }
}