Distinguishing form being built for rendering versus submission
Take a look at the $form_state elements. You'll want to look at 'submitted', 'rebuild', 'cache', 'programmed', etc... depending on your use-case.  You can get a good idea of those elements and what they mean in drupal_build_form.  I typically use $form_state['submitted'].