Show an Acrobat PDF Submit Button When Two Fields Are Filled
Question details
Show a PDF form's Submit button only when at least two of three contact fields contain values.

- Product
- Adobe Acrobat PDF forms
- Device & OS
- not provided
- Scenario
- A fillable PDF contains address, phone, and email fields and a Submit button.
- Observed behavior
- The Submit button should be visible when any two or all three fields are filled and hidden otherwise.
Open the PDF in Acrobat and use Prepare a form to check the exact names of the three text fields and the Submit button. Make sure Acrobat JavaScript and automatic form calculations are enabled in Preferences.
Use an Acrobat calculation script to control the Submit button
Count the nonempty contact fields after a form value changes and show the button when the count reaches two.
This script checks whether fields contain non-whitespace text; it does not verify that the address, phone number, or email is valid. The button still needs its own submit action.
In Acrobat, open All tools > Prepare a form. Confirm the contact fields are named address, phone, and email and the button is named Submit, or replace those names in the script with your actual field names.
Open the Submit button's Properties, select the General tab, and set Form Field to Hidden. On the Actions tab, confirm that the button has the intended Submit a form action.
In Prepare a form, add a text field named contactCount. Open its Properties, set Form Field to Hidden on the General tab, and select Custom calculation script on the Calculate tab.
Click Edit next to Custom calculation script and enter: var names = ["address", "phone", "email"]; var count = 0; for (var i = 0; i < names.length; i++) { var value = this.getField(names[i]).valueAsString; if (value.replace(/^\s+|\s+$/g, "") !== "") count++; } this.getField("Submit").display = count >= 2 ? display.visible : display.hidden; event.value = count;
Save the PDF and use Preview in Prepare a form. Fill and leave each field to commit its value: the button should appear for any two filled fields, including phone and email, and disappear when fewer than two 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 Office documents and viewing PDFs. It can help you move between common file formats, but the Acrobat-specific button script should be created and tested in Acrobat.

Frequently Asked Questions
Will the button appear if only phone and email are filled?
Yes. The calculation counts all three named fields equally, so any pair of nonempty fields makes the Submit button visible.
What happens if a field contains only spaces?
The script removes leading and trailing whitespace before counting, so a field containing only spaces does not count as filled.
Does showing the button automatically submit the form?
No. In Prepare a form, open the button's Properties and use the Actions tab to configure the appropriate Submit a form action.
Why isn't the button changing when I fill in fields?
Check that the field names in the script match those in Prepare a form, then check Acrobat Preferences for JavaScript and automatic form calculation settings. Leave the edited field to commit its value and test again.
Will the visibility rule work in every PDF viewer?
Not necessarily. The rule uses Acrobat form JavaScript, which some PDF viewers do not support. Test the saved form in the viewer your recipients will use.




