Clear Invalid PDF Form Entries in Adobe Acrobat
Question details
Configure a PDF form field to notify users and clear blank or prohibited entries without unnecessarily locking the form.

- Product
- Adobe Acrobat Pro PDF forms
- Device & OS
- not provided
- Scenario
- A form creator wants a name field to reject blank values and entries such as n/a, self, or none.
- Observed behavior
- Invalid entries should be cleared with a helpful message while users remain free to save or close the document.
Open the PDF in Adobe Acrobat Pro and confirm that the field is an editable text field. Check its exact field name in Prepare a Form, since the script must reference that name.
Clear prohibited entries when the user leaves the field
Use an On Blur action to clear invalid text and alert the user without forcing focus back into the field.
This example checks a text field named Full Name. It treats blank entries and the exact values n/a, self, and none as invalid, regardless of capitalization or surrounding spaces.
In Adobe Acrobat Pro, open the PDF and select All tools > Prepare a form. Double-click the name field to open Properties, and confirm its name on the General tab.
Open the Actions tab, choose On Blur as the trigger and Run a JavaScript as the action, then select Add.
In the JavaScript editor, enter the following script, replacing Full Name with the exact field name if needed: var field = this.getField("Full Name"); var value = String(field.value).replace(/^\s+|\s+$/g, ""); if (value === "" || /^(n\/a|self|none)$/i.test(value)) { field.value = ""; app.alert("Please enter a valid name."); }
On the General tab of the field properties, select Required if the form uses a submission workflow. Close Properties and save the PDF.
Use Preview in Prepare a form to enter n/a, self, none, and a valid name. Leave the field after each entry and verify that invalid values are cleared and valid values remain.

Work with PDF forms and Office files in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office documents. It supports common Microsoft Office formats for an easy move between applications, but it does not fix or replace Acrobat's PDF JavaScript validation.

Frequently Asked Questions
Does setting event.rc to false clear a PDF form field?
In an Acrobat Validate action, event.rc = false rejects the proposed value and generally restores the previous value; it does not necessarily leave the field empty. Use an On Blur action that assigns an empty string if clearing is the goal.
Can users still save or close the PDF if the name is invalid?
The On Blur script clears the invalid entry and shows an alert without explicitly returning focus to the field. After dismissing the alert, users can generally save or close the PDF; test this in their intended viewer.
Will the Required setting stop someone from saving an incomplete form?
Not generally. In Acrobat, the Required field property is primarily checked during form submission. It should not be relied on to block an ordinary save or close.
Why does the validation script not run in every PDF viewer?
Some PDF viewers do not support Acrobat JavaScript or have it disabled. Test the form in the recipient's viewer and check its JavaScript settings before distributing the PDF.




