if statement with content of a form
Sounds like something to put in the field or form validation.

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


or 

$form['your_field']['#element_validate'] =&gt; array('_field_callback_validate'),