How to bypass required fields in form validation function of a module? I have a form with two radios and two forms related to each of them. These forms have some required fields. user can just check one radio and then fill in one form. but then clicks on submit button drupal gives error for those unselected and empty field ( which are required but now they are not required because their radio isn't selected) . 

How can I bypass those required inputs in my module ? I am developing my module's form with Form API.
If you are building your own form, you need to remove '#required' =&gt; TRUE, from field to bypass validation or assign FALSE value.

Example with required field:

$form['title'] = array(
  '#type' =&gt; 'textfield', 
  '#title' =&gt; t('Subject'), 
  '#default_value' =&gt; 'whatever', 
  '#size' =&gt; 60, 
  '#required' =&gt; TRUE, // remove this if you want to bypass or give it FALSE value
);


Check Form API Reference for more details

Now you can do the same for existing form by alter the form using hook_alter_form and unset required attribute or assign FALSE value.

Example:

function mymodule_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  if($form_id == 'FORM_ID') {
    $form['FIELD_NAME']['#required'] = FALSE;
    // or
    unset($form['FIELD_NAME']['#required']);
  }
}