How to Allow Only Alphabetic Characters in an Acrobat Form Field
Question details
The user wants to configure a PDF form field to accept only letters (alphabetic characters) while automatically rejecting numbers and special characters.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating or formatting an interactive PDF form where specific text fields must strictly contain alphabetical inputs, such as a First Name or Last Name field.
- Observed behavior
- By default, PDF text fields accept all characters. The user needs to enforce an alphabetical-only input restriction using a custom JavaScript keystroke script.
Ensure your PDF editor supports JavaScript for form fields (such as Adobe Acrobat Pro) and that your document is opened in form preparation mode.
Apply a Custom Keystroke Script to the Form Field
Use Adobe Acrobat's built-in custom format settings to add a JavaScript keystroke script that validates inputs in real-time.
By utilizing a custom keystroke script, you can intercept the characters typed by the user. The script uses a regular expression to test if the character is a letter. If the character is a number or symbol, the script rejects the input instantly.
Open your PDF document in Adobe Acrobat. Go to 'Tools' and select 'Prepare Form' to enable form editing.
Right-click the specific text field you want to restrict and select 'Properties' from the context menu.
In the Properties dialog box, click on the 'Format' tab located at the top.
Click the 'Select format category' drop-down menu and choose 'Custom'.
In the 'Custom Keystroke Script' box, click 'Edit' and paste the following script exactly: if (event.value) event.rc = /^[a-z]*$/i.test(event.change); Click 'OK' to save.
Close the Properties dialog and click 'Preview' at the top right. Try typing numbers and letters into the field to ensure only alphabetic characters are accepted.

Create and Edit PDF Forms Seamlessly with WPS PDF
While advanced JavaScript validations require specific configurations, WPS Office provides a comprehensive and highly compatible PDF editor for creating, editing, and filling interactive PDF forms effortlessly.
- 1. Download and Install: Download WPS Office Free and install it on your device.
- 2. Open the PDF File: Launch WPS PDF and open your existing PDF document.
- 3. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to view form editing options.
- 4. Edit Form Fields: Select 'Text Field' to insert a new field or click an existing field to modify its properties.
- 5. Save the Document: Once your form fields are configured, save your fillable PDF document securely.

Frequently Asked Questions
Can I restrict a PDF form field to accept only numbers?
Yes. In the form field properties, you can navigate to the 'Format' tab and select 'Number' from the format category drop-down. Alternatively, you can use a similar custom keystroke script designed specifically for numeric inputs.
Will JavaScript form validations work on all PDF readers?
Custom keystroke scripts work perfectly on robust desktop PDF readers like Adobe Acrobat and advanced PDF editors. However, some basic web browsers or mobile PDF viewers might not fully support JavaScript execution, potentially allowing users to bypass the restriction.
How do I apply the alphabetical restriction to multiple fields simultaneously?
While in form editing mode, you can hold the Ctrl (or Cmd) key to select multiple text fields. Right-click any of the selected fields, open 'Properties', and apply the custom keystroke script in the 'Format' tab once to update all selected fields at the same time.




