gppa_should_trigger_change (JS)

  1. Description
  2. Usage
  3. Parameters
  4. Examples
    1. Require input to have at least 4 characters before triggering a change.
  5. Since

Description

Override when fields and Live Merge Tag values are refreshed when dependent inputs change.

A common use of this filter is to require a certain number of characters in inputs before triggering an update.

Usage

gform.addFilter( 'gppa_should_trigger_change', 'my_custom_function' );

Parameters

  • triggerChange boolean

    Whether or not to trigger update of fields and Live Merge Tags. Default: true

  • formId string

    The current form ID.

  • inputId string

    The ID of the input that had a change event triggered.

  • $el JQuery

    Input element that had change event.

  • event JQueryEventObject

    Original event on input.

Examples

Require input to have at least 4 characters before triggering a change.

/**
 * Gravity Perks // Populate Anything // Require a Minimum Character Count Before Triggering a Change
 * https://gravitywiz.comhttps://gravitywiz.com/documentation/gravity-forms-populate-anything/
 *
 * 1. Install this snippet with our free Custom JavaScript plugin.
 *    https://gravitywiz.com/gravity-forms-code-chest/
 */
window.gform.addFilter('gppa_should_trigger_change', function( triggerChange, formId, inputId, $el, event ) {
	// Update "1" to the field ID.
	if ( inputId == 1 ) {
		// Require length for input 1 to be at least 4.
		if ( event.currentTarget.value.length < 4 ) {
			return false;
		}
	}

	return triggerChange;
} );

Since

This JavaScript filter is available since Gravity Forms Populate Anything 1.0-beta-5.20.