PDF Editing Issues

Apply the Same On Blur Script to All Acrobat PDF Form Fields

Ayan MasoodAyan Masood Nov 18, 2026 868 views

Question details

Apply the same custom On Blur JavaScript action to multiple PDF form fields.

Apply the Same On Blur Script to All Acrobat PDF Form Fields
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A form creator wants multiple fields to run the same script when a user moves focus away from a field.
Observed behavior
The form creator needs a way to assign the action because default field properties do not include actions.
Before you start

Create the form fields first in Acrobat Pro and make sure Acrobat JavaScript is enabled in Preferences. Decide which fields should receive the action, as assigning a new On Blur action replaces any existing action for that trigger.

Solution 1Recommended

Assign an On Blur action with the Acrobat JavaScript console

Use a console script to apply the same action to the form fields already in the PDF.

Acrobat does not generally let you set an On Blur action as the default for every newly created field. Run the assignment again for fields added later.

1
Open the JavaScript console

Open the PDF in Acrobat Pro, then open the JavaScript console from All tools > Use JavaScript > JavaScript debugger. The menu name may vary by Acrobat version.

2
Prepare the action script

In the console, enter this example, replacing the text inside blurScript with your own JavaScript: var blurScript = "console.println('Blur: ' + event.target.name);"; for (var i = 0; i < this.numFields; i++) { var field = this.getField(this.getNthFieldName(i)); if (field) field.setAction('OnBlur', blurScript); }

3
Run the assignment

Select the complete script in the console and execute it. In Windows, you can press Ctrl+Enter. The loop assigns the action to every field it retrieves; modify it to filter field names if only some fields should receive the action.

4
Save and test the form

Choose File > Save, then interact with several fields and move focus away from each one. With the example action, check the JavaScript console for the field names.

Assign an On Blur action with the Acrobat JavaScript console
Existing actions are replaced: Setting an On Blur action replaces the existing action for that trigger on each affected field. Test the form in the PDF viewer your audience will use, because JavaScript support varies by viewer.
Free Microsoft Office alternative

Work with PDFs and Office files in WPS Office

WPS Office is a free, lightweight Office alternative with a familiar interface for working with documents, spreadsheets, presentations, and PDFs. Its Microsoft Office format compatibility makes it easier to migrate existing files. Use Acrobat for assigning the JavaScript form actions described above.

Open and work with PDF documents alongside other office filesCompatible with Microsoft Word, Excel, and PowerPoint formats, including DOCX, XLSX, and PPTXFamiliar interface for an easier transition from Microsoft OfficeFree, lightweight option for everyday office work
microsoft office alternative - wps office

Frequently Asked Questions

Can I make an On Blur action the default for new Acrobat fields?

Acrobat does not generally include actions in the default properties applied to new fields. Create the fields first, then assign the action with a script.

Will the script overwrite existing field actions?

The setAction('OnBlur', ...) call replaces the existing On Blur action on each affected field. Review existing actions in Prepare a form before running the script.

How can I apply the action to only some fields?

Modify the console loop to check each field name before calling setAction. For example, apply the action only when the name starts with a prefix used by the target fields.

Why doesn't the action run in another PDF viewer?

PDF viewers vary in their support for Acrobat JavaScript and form actions. Test the saved form in the viewer your recipients will use and check whether JavaScript is enabled.