Webform custom validation red highlight How can I add the red error border to a webform component programmatically?

I am doing so custom form validation when the form submits and I need to set the red border on under rules very specific to my module.

Currently, I am doing the following:

form_set_error('email_address', 'Please supply matching email addresses');


It adds an error message and stops the form from being submitted but it does not highlight the form field I am validating. That makes it difficult for the users to see the problem area at a glance
You can use Webform Validation. This module includes a lot of validations for webform elements.

Alternatively, you can code your own validation yous adding your validation function to the desired forms. Then use form_set_error to mark wrong element with red border.

Webform puts the fields inside a group, so if you need to mark a field as not valid you must provide the full hierarchy.

For example, for this field in $form:

$form['submitted']['form_contact_data']['form_contact_email'] = array(
...
);


You can mark it as erroneous with:

form_set_error('submitted][form_contact_data][form_contact_email', 'Error message');


In this example the filed is inside two groups: the first, 'submitted' is the main Webform group. The second, 'form_contact_data', is a field group created where I've placed contact data fields for this webform.