# Accessibility: using role="alert" for validation errors

**URL:** <https://community.gravityforms.com/t/accessibility-using-role-alert-for-validation-errors/13556>\
**Category:** Get Help\
**Tags:** validation-error\
**Created:** [October 4, 2022, 8:00am UTC](https://community.gravityforms.com/t/accessibility-using-role-alert-for-validation-errors/13556 "2022-10-04T08:00:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mhoogma](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/mhoogma/32/5906_2.png) [@mhoogma](https://community.gravityforms.com/u/mhoogma)\
**Post date:** [October 4, 2022, 8:00am UTC](https://community.gravityforms.com/t/accessibility-using-role-alert-for-validation-errors/13556/1 "2022-10-04T08:00:50Z")

</div>

To announce a dynamic change, I have added `role="alert"` to `<div class="validation_error">`. This `<div>` appears after page reload, but Accessibility experts say the empty container with `role="alert"` should already be present in the HTML. Otherwise screen readers can’t present the error correctly.

[MDN](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Alert_Role) also explains why an empty container must be present.

I have two questions about this:

- Why does Gravity add the `<div>` with the validation error after reload?
- How can we create an empty div, to which the validation error can be added? Or do you have other suggestions to handle this?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/gravityforms1/original/2X/f/fef63f0599c45e0218c30d9f5d7ca8bff9b00189.png) [@system](https://community.gravityforms.com/u/system)\
**Post date:** [November 3, 2022, 8:01am UTC](https://community.gravityforms.com/t/accessibility-using-role-alert-for-validation-errors/13556/2 "2022-11-03T08:01:10Z")

</div>

Closed on November 3, 2022, 8:01am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
