PDF Editing Issues

How to Allow Spaces and Special Characters in Acrobat PDF Text Fields

John WilsonJohn Wilson Nov 3, 2026 869 views

Question details

The user needs to configure a custom validation script in a PDF text field to allow English letters and numbers, as well as spaces, periods, and specific special characters without rejecting them.

How to Allow Spaces and Special Characters in Acrobat PDF Text Fields
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Creating a custom JavaScript validation script for a PDF form text field to restrict user input to a specific character set.
Observed behavior
The current validation script rejects valid characters such as spaces, periods, and ampersands, even though they were intended to be permitted alongside standard English letters and numbers.
Before you start

Ensure you have access to the form editing tools in your PDF editor and a basic understanding of JavaScript regular expressions (Regex).

Solution 1Recommended

Update the Regular Expression Character Class in Your Script

Modify the custom validation script to explicitly include the space character, period, and any other required special characters within the regex square brackets.

Regular expressions (regex) use character classes enclosed in square brackets to define exactly which characters are permitted. If a space or period is missing from this class, the script will reject the input.

By placing every permitted character (like spaces, periods, and ampersands) directly inside the regular expression character class, the validation will accurately pass supported inputs while triggering an alert only for unsupported characters.

1
Open PDF Form Properties

In your PDF editing software, enter the Form Preparation mode. Right-click the specific text field you want to validate and select 'Properties'.

2
Navigate to the Validation Tab

Click on the 'Validate' tab in the Properties dialog box and select 'Run custom validation script' from the available options.

3
Edit the Validation Script

Click the 'Edit' button and input the updated regex script. For example: var pattern = /^[0-9a-zA-Z .&-]*$/; event.rc = pattern.test(event.value); if (!event.rc) app.alert("English Characters and Approved Punctuation Only");

4
Save and Test

Click 'OK' to save the script, close the Properties window, and switch back to the standard preview mode to test the text field with spaces and special characters.

Update the Regular Expression Character Class in Your Script
Language Detection Limitations: This script only validates whether the individual typed characters belong to the permitted list (e.g., standard alphabet and basic punctuation). It does not determine if the words formed actually make sense in English or any other language.
Comprehensive PDF Form Solution

Easily Create and Fill PDF Forms with WPS Office

If you frequently work with PDF forms and need a reliable, lightweight application, WPS PDF provides excellent tools for editing, form filling, and document formatting without complex configurations.

  1. 1. Open WPS Office: Launch WPS Office and click on the 'PDF' tab from the home screen.
  2. 2. Open Your PDF Form: Click 'Open' and select the PDF form document you want to edit or fill.
  3. 3. Use Form and Edit Tools: Navigate to the 'Edit' or 'Form' tab on the top ribbon to easily input text, modify existing content, or fill out interactive fields without needing complex scripts.
Fully compatible with standard PDF formats and form fieldsIntuitive tools to easily insert text, manage pages, and fill formsLightweight application that runs smoothly on all major operating systemsBuilt-in PDF conversion tools to switch seamlessly between Word, Excel, and PDF
QA img-9

Frequently Asked Questions

Why does my PDF form field reject spaces even when I allow text?

Standard alphabetic validation patterns often only include A-Z and a-z. To allow spaces, you must explicitly type a space character within the square brackets of your validation script's regular expression.

Can a JavaScript validation script detect if the text entered is valid English?

No, a standard regular expression script only checks if the entered characters belong to a permitted set (like the Latin alphabet). It cannot verify grammar, vocabulary, or the language context of the sentence.

How do I add an ampersand or hyphen to my regex character class?

You can add special characters like ampersands directly inside the square brackets. For hyphens, place them at the very end of the character class (e.g., [a-zA-Z .&-]) so the system interprets it as a literal hyphen rather than a character range.