Creating conditional fields: How should I implement hook_form_alter()?
The Conditional Fields module's features can be done with using #states attribute from form api in D7.

If you want to implement it, of course you need to use hook_form_alter() to bring additionaly attributes on existing fields. There many tutorials about the usage of hook_form_alter().

Example of using of #states attribute:

  $form['student_type'] = array(
    '#type' =&gt; 'radios',
    '#options' =&gt; array(
      'high_school'   =&gt; t('High School'),
      'undergraduate' =&gt; t('Undergraduate'),
      'graduate'      =&gt; t('Graduate'),
    ),
    '#title' =&gt; t('What type of student are you?')
  );
  $form['high_school'] = array(
    '#type' =&gt; 'fieldset',
    '#title' =&gt; t('High School Information'),
    // This #states rule says that the "high school" fieldset should only
    // be shown if the "student_type" form element is set to "High School".
    '#states' =&gt; array(
      'visible' =&gt; array(
        ':input[name="student_type"]' =&gt; array('value' =&gt; 'high_school'),
      ),
    ),
  );


Example from Examples for Developers module - form_example module