How to make a required / not required one field depending on value of second field (Drupal in registration form) Below is an example of code that makes the first field not required in the form

&lt;?php
    function мой_модуль_form_alter(&amp;$form, &amp;$form_state, $form_id){
    $form['field_website']['und'][0]['#required'] = FALSE;
    }
?&gt;




$form['test']['und'][0]['value']=test;


But I need to check the content in the second field after sending the form, and if it coincides with the value of "test", then the first field became not required.

if($form['test']['und'][0]['value']=='test'){
    $form['field_website']['und'][0]['#required'] = FALSE;
}
Use Conditional Fields module.