Require a Minimum Character Count Before Triggering a Change

  1. Install this snippet with our free Custom JavaScript plugin. https://gravitywiz.com/gravity-forms-code-chest/
Read the Walkthrough

Code

Filename: gppa-require-min-chars-before-trigger.js

/**
 * 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;
} );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.