How to Enforce a Minimum Word Count in an Acrobat PDF Form
Question details
The user wants to set a minimum word count of at least 50 words for a specific text field (Business Description) in a PDF form, while still allowing the field to be left completely blank.

- Product
- Adobe Acrobat Pro
- Device & OS
- not provided
- Scenario
- Designing interactive PDF forms where specific text inputs require detailed answers, but making the field optional so it can be bypassed if unneeded.
- Observed behavior
- Standard PDF form settings do not natively support minimum word count rules. If left unconfigured, users can enter any amount of text, requiring a custom script to enforce the 50-word minimum threshold.
Ensure you have access to the 'Prepare Form' tools in your PDF editor and a basic understanding of adding JavaScript code to form field properties.
Use a Custom JavaScript Validation Script
Apply a custom JavaScript snippet to the text field's validation tab to count the words and reject the input if it falls below the minimum requirement.
Acrobat JavaScript can be used to read the field's value, trim excess spaces, and split the text into an array of words to count them. By adding conditional logic, you can allow an empty value to pass validation but enforce the 50-word minimum if the user chooses to enter text.
Open your PDF document in Adobe Acrobat Pro, navigate to the 'Tools' menu, and select 'Prepare Form'.
Right-click on the target text field (e.g., Business Description) and select 'Properties' from the context menu.
Go to the 'Validate' tab in the Properties dialog. Select 'Run custom validation script' and click the 'Edit' button.
Input a script that trims the value and checks the word count. For example: var v = event.value.replace(/^\s+|\s+$/g, ''); if (v !== '') { var wordCount = v.split(/\s+/).length; if (wordCount < 50) { app.alert('Please enter at least 50 words.'); event.rc = false; } }
Click 'OK' to close the editor, then 'Close' the properties window. Switch to 'Preview' mode to test entering fewer than 50 words, as well as leaving the field blank.

Design Interactive PDF Forms easily with WPS Office
While advanced JavaScript validation solves specific Acrobat workflow needs, WPS Office offers a highly intuitive and powerful PDF editor for creating, formatting, and managing interactive form fields with ease.
- 1. Open WPS PDF: Launch WPS Office and open your PDF document using the built-in PDF editor.
- 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to access the interactive form creation tools.
- 3. Add a Text Field: Click on 'Text Field' and click anywhere on the document to place the input box.
- 4. Customize Field Settings: Double-click the newly inserted text field to open its properties, where you can adjust multi-line settings, font sizes, and appearance.

Frequently Asked Questions
Can I enforce a maximum word count in a PDF form field natively?
While you cannot enforce a maximum word count natively without JavaScript, you can easily enforce a maximum character limit by checking 'Limit of characters' in the 'Options' tab of the text field properties.
Why does my validation script trigger when the field is empty?
If your custom JavaScript does not explicitly include a condition to allow empty strings (e.g., checking if the value is not equal to ''), the script will process zero words as being less than your 50-word minimum and trigger the error alert.
How can I prevent a user from saving the PDF if validation fails?
Field-level validation alone does not prevent saving. To stop submission or saving, you must move the validation logic to a custom 'Submit' button or use document-level JavaScript tied to the 'Will Save' event to check field lengths.




