drupal_add_js not work in form validation failed I add js file with drupal_add_js in hook_form_alter, it is ok and I see it in list of js loaded in page, but when I submit form and form not validate and return to that form (after validation failed) I don't see js files that added to form, why this happened? and how can add my js file in that form after validation failed ? 

some part of my code 

function mymodle_form_alter(&amp;$form, $form_state, $form_id) {
  if ($form_id == 'news_node_form') {
    drupal_add_js(drupal_get_path('module', 'mymodule') . '/js/mymodulejsfile.js'); //, array('scope' =&gt; 'footer','weight' =&gt; 10));
  }
}


code work correctly in add and edit form, but when form submit and validation failed it show validation error but my js file not loaded in page (I checked html source and check firebug script files), but there is not my js file,
Javascripts are lost when the form is rebuilt when using drupal_add_js(). Use $form['#attached'] instead. Also, it's better to use hook_form_FORM_ID_alter() instead of a general hook_form_alter(). hook_form_alter() will run for every form on the page. Try using the below:

function mymodule_form_news_node_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  $form['#attached']['js'] = array(
    drupal_get_path('module', 'mymodule') . '/js/mymodulejsfile.js',
  );
}