Activate or DeActivate requirement status of field based on another field I want to alter a form in my drupal 7 project.
I want to activate or deactivate requirement status of a field programmatically based on another field value.

if field value is male , military status field must be required but if it is female, military status is not required and also it must be hide.

Please guide me in this issue.
What you could do is make the military field not required. Then add your own validate function to the form with:

$form['#validate'][] = 'my_function_name';


Then in your function you can do a check e.g. 

function my_function_name*$form, &amp;$form_state){
  if($form_state['values']['my_gender_field'] == 'male' &amp;&amp; empty($form_state['values']['my_military_field'])){
     form_set_error('my_military_field', 'Military field is required');
  }
}


Or you could try using #states from the form API which has a 'required' option:
https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7.x#states