PDF Editing Issues

Move an Adobe Acrobat Form Field When Another Field Is Empty

Olivia MillerOlivia Miller Nov 19, 2026 869 views

Question details

The user wants a PDF text field to move when another field is empty.

Move an Adobe Acrobat Form Field When Another Field Is Empty
Product
Adobe Acrobat
Device & OS
not provided
Scenario
A fillable PDF contains two text fields, and the second should move upward when the first has no value.
Observed behavior
The desired behavior is for the second field to change position based on the first field's value.
Before you start

Open the PDF in Adobe Acrobat and check the exact names of the two fields in Prepare a form. Make sure JavaScript is enabled and decide whether the moved field should overlap the empty field.

Solution 1Recommended

Change the second field's rectangle with Acrobat JavaScript

Use a validation script to move text1.2 to the top of text1.1 when text1.1 is empty, and restore its original position when a value is entered.

A field's rect property contains its left, top, right, and bottom coordinates. This example assumes both fields are on the same page and deliberately places the second field over the first when the first is empty.

The script runs when the value of text1.1 is committed. If the form must also be positioned when it first opens, an additional initialization script is needed.

1
Find the original coordinates

Open the JavaScript Debugger in Acrobat, using Ctrl+J on Windows, and run console.println(this.getField("text1.2").rect.join(", "));. Record the four values printed in the console.

2
Open the validation script

Open Prepare a form, right-click text1.1, and choose Properties. On the Validate tab, select Run custom validation script and click Edit.

3
Enter the positioning script

Paste the following script into the editor. Replace the four example numbers in base with the original coordinates recorded for text1.2: var target = this.getField("text1.2"); var upper = this.getField("text1.1"); var base = [100, 500, 250, 480]; var value = event.value == null ? "" : String(event.value); if (/^\s*$/.test(value)) { var shift = upper.rect[1] - base[1]; target.rect = [base[0], base[1] + shift, base[2], base[3] + shift]; } else { target.rect = base; }

4
Test both states

Save the script, close the Properties dialog, and preview the form. Clear text1.1 and leave the field to commit the change; then enter a value and leave the field again to check that text1.2 returns to its original position.

Change the second field's rectangle with Acrobat JavaScript
Check the field layout: Adjust the coordinates if the fields should not overlap. Existing validation scripts may need to be combined with this code rather than replaced. JavaScript support and permissions can vary between PDF viewers.
Free Microsoft Office alternative

Edit PDFs and Office Files with WPS Office

WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office files. Its format compatibility makes it easier to move existing documents into your workflow. For the conditional field movement in this article, use Adobe Acrobat JavaScript; WPS does not replace that Acrobat-specific script.

Open and work with PDF documents alongside Office filesCompatible with Microsoft Word, Excel, and PowerPoint formatsFamiliar interface for a smoother transition from Microsoft OfficeFree and lightweight for everyday document tasks
microsoft office alternative - wps office

Frequently Asked Questions

What does the rect property control in Acrobat?

The rect property sets a field's bounding rectangle as four coordinates: left, top, right, and bottom. Assign a new rectangle with this.getField("fieldName").rect to change the field's position or size.

How do I restore the field when the first field is filled in?

Record the second field's original rectangle in the Acrobat JavaScript Debugger and use those coordinates as the base array. The example script assigns that array back to text1.2 when text1.1 contains a value.

Why does the moved field overlap the empty field?

The example aligns the top of text1.2 with the top of text1.1, so overlap is intentional. Change the shift calculation or choose different destination coordinates if you want the fields to remain separate.

Will the field move as soon as the PDF opens?

Not with the validation script alone. It runs when the value of text1.1 is committed. To set the initial position on opening, add an appropriate initialization script and test it in the intended PDF viewer.