This is because on form error the form comes out of the cache table and skips fetching the form and all its _alter's. The 'best' practice I have found is to use a #pre_render function to drupal_add_js(). pre_render's are called always.<div>
<?php</div><div>function my_form_alter() {</div><div> // add my elements</div><div> $form['#pre_render'][] = 'my_load_js';</div><div>}</div><div>?></div><div><br></div><div><?php</div><div>function my_load_js($form) {</div>
<div> drupal_add_js();</div><div> return $form;</div><div>}</div><div>?><br clear="all"><br>-- <br>Scott Reynolds<br>
</div>