Docs & Support

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

frm_invalid_error_message

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.

The frm_invalid_error_message hook allows the modification of the message shown at the top of a form when there is an invalid field entry. The default invalid field message says "There was a problem with your submission. Errors are marked below."

Since Formidable Forms 7.0, the value passed to this hook also includes a clickable list of the fields that failed validation. The message is wrapped in a <span>, and the list follows it in a <ul>. If your function returns new text in place of $invalid_msg, the list is removed too. To change only the message, keep the <ul> part, as in the second example below.

Usage

add_filter( 'frm_invalid_error_message', 'change_frm_form_error_message', 10, 2 );

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

Parameters

  • $invalid_msg (string): The HTML shown at the top of the form. Since 7.0, this is the message in a <span>, followed by the list of field errors in a <ul> when the list is turned on.
  • $args (array):
    • 'form' (object): The form being submitted.
    • 'errors' (array): The validation errors, keyed by field (for example, 'field25').
    These 2 keys are always set. When the form isn't submitted with AJAX, $args also includes 'fields' and 'img'.

Examples

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

Change the invalid field message for a single form

Use the code below to change the invalid field error message for a single form. Replace 123 with the ID of your form. Replace 'My custom error message' with your custom error message. This replaces the whole value, so the clickable list of field errors isn't shown for this form.

add_filter( 'frm_invalid_error_message', 'change_frm_form_error_message', 10, 2 );
function change_frm_form_error_message( $invalid_msg, $args ) {
    if ( isset( $args['form'] ) && (int) $args['form']->id === 123 ) {
        $invalid_msg = 'My custom error message';
    }
    return $invalid_msg;
}

Change the message and keep the list of field errors

Use the code below to change the message for a single form while keeping the clickable list of field errors under it. Replace 123 with the ID of your form, and 'My custom error message' with your message.

add_filter( 'frm_invalid_error_message', 'change_frm_form_error_message_keep_list', 10, 2 );
function change_frm_form_error_message_keep_list( $invalid_msg, $args ) {
    if ( ! isset( $args['form'] ) || (int) $args['form']->id !== 123 ) {
        return $invalid_msg;
    }

    // Keep the list of field errors (the <ul> part), if there is one.
    $error_list = strstr( $invalid_msg, '<ul>' );

    return '<span>My custom error message</span>' . ( $error_list ? $error_list : '' );
}

Change Log

  • Added in version 2.02.07.
  • Version 7.0: $invalid_msg includes the clickable list of field errors.
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