Capture Word Count as Field Value

Use ths snippet alongside our GF Custom JavaScript plugin to capture the number of words in another field. This is useful if you’d like to implement conditional logic based on the number of words.

Code

Filename: gpppw-capture-count-as-field-value.js

/**
 * Gravity Perks // Pay Per Word // Capture Word Count as Field Value
 * https://gravitywiz.com/documentation/gravity-forms-pay-per-word/
 *
 * Use ths snippet alongside our [GF Custom JavaScript][1] plugin to capture the number of words
 * in another field. This is useful if you'd like to implement conditional logic based on the
 * number of words.
 *
 * [1]: https://gravitywiz.com/gravity-forms-code-chest/
 */
gform.addFilter( 'gpppw_word_count', function( wordCount ) {
  // Update "4" to the ID of the field which should be populated with the word count.
	$( '#input_GFFORMID_4' ).val( wordCount ).change();
}, 11 );

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.