I’m working with Drupal 7.56 and I am using the Webform module to create a custom form.
I used hook_form_alter()
in a custom module to add a validation test.
function mymodule_form_alter(&$form, &$form_state, $form_id) { if ($form_id=='webform_client_form_1') { $form['#validate'][]='mymodule_form_validate'; return $form; } } function mymodule_form_validate($form, &$form_state) { $aux = $form_state['values']['submitted']['aux']; if ($aux != '') { if( /* my test */ ) { $text = t('Please check your input'); form_set_error('aux', $text); } } }
How can I add the error class when my test fails?