 <p>A bit late, but maybe it will still help you or someone else looking for this, the messages are themed in <a href="http://api.drupal.org/api/drupal/includes--theme.inc/function/theme_status_messages/6" rel="nofollow">theme_status_messages()</a> but you don't have any context about them at this point. However...</p> <p>Form errors are added through <a href="http://api.drupal.org/api/drupal/includes--form.inc/function/form_set_error/6" rel="nofollow">form_set_error()</a>, which stores them in an static array according to the form field name, you can access that through <a href="http://api.drupal.org/api/drupal/includes--form.inc/function/form_get_errors/6" rel="nofollow">form_get_errors()</a>.</p> <p>Now, you can load these errors and then look up the error messages in that error array and use the key as the id.</p>