I created a field with Radio buttons and when it fails to validate, there is no red highlight around it.

enter image description here

There is only an error message at the top.

enter image description here

How can I add a custom CSS class to any radio button fields upon a failed validation?

I am already altering this form with hook_form_alter(); and have a custom validation function, so I am willing to work on a custom module for this but just need some help being pointed in the right direction.

I would ideally like to add a ".error" class or something to this div and customize it in my CSS to also give it a red border.

How can this be acheived?

enter image description here

1 Answer 1


Out of the box webforms created with Drupal core and the Webform module do not have in line error messaging and indicators for each form field.

You can either:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.