gform_input_change

gform_input_change

DescriptionUsageParametersExamplesPlacementSinceSource Code

Description
This JavaScript hook allows further actions to be performed when the keyup or change event is fired for an HTML input. The action only fires when the form is an AJAX form or has one of the following:

Calculation
CAPTCHA Field
Checkbox Field
Conditional Logic
Credit Card Field
Drop Down or Multi Select Field with the Enable enhanced user interface turned on
File Upload Field
JavaScript Merge Tags
List Field
Number Field Set to Currency
Page Field
Password Field with Enable Password Strength turned on
Price Field
Repeater Field

Usage
gform.addAction( 'gform_input_change', function( elem, formId, fieldId ) {
//do something
}, 10, 3 );

Parameters

elem
Window object.

formId
The ID of the current form.

fieldId
The field ID of the current field.

Examples
The example below can be found in Gravity Forms in the file js/conditional_logic.js .
gform.addAction( 'gform_input_change', function( elem, formId, fieldId ) {
if( ! window.gf_form_conditional_logic ) {
return;
}
var dependentFieldIds = rgars( gf_form_conditional_logic, [ formId, 'fields', gformExtractFieldId( fieldId ) ].join( '/' ) );
if( dependentFieldIds ) {
gf_apply_rules( formId, dependentFieldIds );
}
}, 10 );

Placement
Your code snippet can be placed in a HTML field on your form or in a theme custom JavaScript file.
Since
This filter was added in Gravity Forms version 1.9.14.
Source Code
This action hook is located in the function gf_input_change in js/gravityforms.js .

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注