bookmark_bordergform_input_mask_script

Description

Use this filter to change the initialization script for the input mask script. Can be used to specify different initialization parameters.

Usage

add_filter( 'gform_input_mask_script', 'set_mask_script', 10, 4 );

To target a specific form append the form id to the hook name. (format: gform_input_mask_script_FORMID)

add_filter( 'gform_input_mask_script_6', 'set_mask_script', 10, 4 );

Parameters

  • $script string

    The script to be filtered.

    $script = "jQuery('#input_{$form['id']}_{$field->id}').mask('" . esc_js( $mask ) . "').bind('keypress', function(e){if(e.which == 13){jQuery(this).blur();} } );";

  • $form_id integer

    ID of current form.

  • $field_id integer

    ID of current field.

  • $mask string

    Currently configured mask retrieved from $field->inputMaskValue.

Examples

This example changes the placeholder character to a blank space (” “)

add_filter( 'gform_input_mask_script_185', 'set_mask_script', 10, 4 );
function set_mask_script( $script, $form_id, $field_id, $mask ) {
    $script = "jQuery('#input_{$form_id}_{$field_id}').mask('" . esc_js( $mask ) . "',{placeholder:' '}).bind('keypress', function(e){if(e.which == 13){jQuery(this).blur();} } );";

    return $script;
}

A full list of available initialization options can be found at:

http://digitalbush.com/projects/masked-input-plugin/

Placement

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

Source Code

gf_apply_filters( 'gform_input_mask_script', $form['id'], $script, $form['id'], $field->id, $mask );

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