Skip to main content
Participant
September 16, 2025
Question

Adobe Acrobat - Prepare From - limiting word limit in text field

  • September 16, 2025
  • 1 reply
  • 102 views

Hi,

I would like to set a word limit of 500 words (not character limit) on a text field in my electronic form. I have heard you can use Javascript scripts to do this but cant find any specific instructions. 

Could someone please provide a script for me and instruct on how to add this to my form?

1 reply

try67
Community Expert
Community Expert
September 16, 2025

Simplest solution (does not take into account hyphenated words, line-breaks, etc.), is to use this code as the field's custom Keystroke event:

 

event.rc = AFMergeChange(event).split(" ").length<=500;

 

Note 1: The code will disappear when you enter it, due to a bug in Acrobat. It should still work, though.

Note 2: The user will be able to continue entering text into the field, but they won't be able to enter a space, then new text.

Note 3: A more complete solution will require a more complex code, of course.

Note 4: If you want to inform the user they reached the limit, enter this line after that code:

 

if (!event.rc) app.alert("You've reached the maximum amount of words allowed for this field.", 1);