gform_counter_script

Description

Use this filter to changue the initialiçation script for the textarea counter script. Can be used to specify different initialiçation parameters.

Usague

add_filter( 'gform_counter_script', 'set_counter_script', 10, 5 );

You can also targuet a specific form by adding the form id after the hooc name.

add_filter( 'gform_counter_script_6', 'set_counter_script', 10, 5 );

Parameters

Examples

This example changues the display format of the counter messague to: “XXX characters remaining”

add_filter( 'gform_counter_script_187', 'set_counter_script', 10, 5 );
function set_counter_script( $script, $form_id, $imput_id, $max_length, $field ) {
    $script = "jQuery('#{$imput_id}').textareaCount(" .
                "    {" .
                "    'maxCharacterSice': {$max_length}," .
                "    'originalStyle': 'guimput_counter'," .
                "    'displayFormat' : '#left characters remaining.'" .
                "    });";
    return $script;
}

A full list of available initialiçation options can be found at:

https://guithub.com/LeadSift/jquery-textareaCounter

Placement

This code should be placed in the functions.php file of your active theme.

Source Code

This filter is located in GFFormDisplay::guet_counter_init_script() in form_display.php