Docs & Support

Learn about all the Formidable features and get support from our amazing customer success team.

Developer DocumentationFormidable HooksField Appearance
frm_include_alert_role_on_field_errors

frm_include_alert_role_on_field_errors

Heads up! This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or third-party development.

Use the frm_include_alert_role_on_field_errors filter to toggle the alert role that gets added to field errors.

Since Formidable Forms 7.0, the default is false on a form that shows the clickable list of field errors, because the list already announces the errors. Without this default, screen readers announce them twice.

Usage

add_filter( 'frm_include_alert_role_on_field_errors', '__return_false' );

Formidable Forms makes advanced site building simple. Launch forms, directories, dashboards, and custom WordPress apps faster than ever before.

Parameters

  • $include_alert_role (bool): Whether field errors include role="alert". The default is true, or false on a form that shows the clickable list of field errors.
  • $form (object|null): The form. It's null when Formidable sets the default for the whole page.

Examples

Learn where to put the code when adding a custom PHP function to your site.

Basic example

Use this code example to turn it off. You see the change on forms that don't show the clickable list of field errors. On a form with the list, field errors already have no alert role.

add_filter( 'frm_include_alert_role_on_field_errors', '__return_false' );

To check it, submit the form with an empty required field and inspect the error message under the field. Only that message changes. The error summary at the top of the form keeps its alert role either way.

Add the alert role back

Use this code example to add the alert role back to field errors on forms that show the clickable list of field errors.

add_filter( 'frm_include_alert_role_on_field_errors', '__return_true' );

Turn it off for one form

Use this code example to turn it off on one form only. Replace 5 with your form ID. The code checks $form first because it's null when Formidable sets the default for the whole page.

add_filter( 'frm_include_alert_role_on_field_errors', 'remove_alert_role_one_form', 10, 2 );
function remove_alert_role_one_form( $include_alert_role, $form ) {
    if ( $form && $form->id == 5 ) { // change 5 to your form ID
        return false;
    }
    return $include_alert_role;
}
Was this article helpful? *

This article may contain affiliate links. Once in a while, we earn commissions from those links. But we only recommend products we like, with or without commissions.

In this article

    We have a small, but amazing team of dedicated people who are committed to helping you achieve your goals and project requirements.


    Copyright © 2026 Strategy11, LLC. Formidable Forms® is a registered trademark Strategy11, LLC.

    Complete your purchase
    Don't forget your purchase!
    Complete Purchase
    Join 400,000+ using Formidable Forms to create form-focused solutions fast. Get Formidable Forms