PDF Editing Issues

Set a PDF Phone Field’s Character Limit Based on Another Field in Acrobat

Steven ParkerSteven Parker Nov 19, 2026 869 views

Question details

Set a PDF phone field’s character limit according to the value of another form field.

Set a PDF Phone Field’s Character Limit Based on Another Field in Acrobat
Product
Adobe Acrobat PDF forms
Device & OS
not provided
Scenario
A PDF form has a country field and a phone field that should allow different maximum lengths for domestic and other selections.
Observed behavior
The phone field should allow 10 characters for the domestic selection and 20 characters for other selections.
Before you start

Open the PDF in Acrobat and check the exact form field names and the country option’s export value. Enable Acrobat JavaScript in Acrobat preferences if it is disabled, and ensure you can edit the form fields.

Solution 1Recommended

Update the Phone Field Limit When the Country Field Loses Focus

Use a field action to apply the appropriate limit before the user enters a phone number.

The script below assumes the fields are named country and phone, and the domestic option has the value domestic. Field names and the comparison value must match your form exactly.

A character limit counts all characters, including spaces and punctuation. It does not check whether a phone number has a valid format.

1
Open the form editor

In Acrobat, open the PDF and choose All tools > Prepare a form. Open the country and phone field properties to confirm their names and the country option’s export value.

2
Set the initial limit

Open the phone field’s Properties > Options and set Limit of characters to match the initial country selection, such as 10 for domestic.

3
Add a country field action

Open the country field’s Properties > Actions. Set Select Trigger to On Blur and Select Action to Run a JavaScript, then click Add.

4
Enter the script

In the JavaScript editor, enter: var phone = this.getField("phone"); if (this.getField("country").value == "domestic") { phone.charLimit = 10; } else { phone.charLimit = 20; } Click OK and close the field properties.

5
Test both selections

Use Preview in Prepare a form, select each country option, click away from the country field, and try typing in the phone field. Also test changing the country after entering a number to check how existing text is handled.

Update the Phone Field Limit When the Country Field Loses Focus
The action runs after leaving the country field: On Blur updates the limit when the country field loses focus, not immediately when its selection changes. Test the saved form in the PDF viewer your recipients will use, because JavaScript support varies.
Free Microsoft Office alternative

Work With PDF 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 moving existing files straightforward. Use Acrobat for the dynamic form JavaScript described above; do not assume it will run in every PDF viewer.

Open and work with PDFs alongside other office filesCompatible with Microsoft Office formats including DOCX, XLSX, and PPTXFamiliar interface makes the transition from Microsoft Office easierFree, lightweight suite for everyday office tasks
microsoft office alternative - wps office

Frequently Asked Questions

Why does the script not recognize the domestic option?

In Prepare a form, open the country field’s Properties and check its field name and option export value. Update the script so country and domestic match those values exactly.

Can I put the script on the phone field instead?

Yes. In the phone field’s Properties > Actions, add an On Blur action that sets event.target.charLimit to 10 or 20 based on the country field. This runs only after the user leaves the phone field, so it does not apply the new limit before typing.

Does a character limit ensure that the phone number is valid?

No. The limit counts characters, including spaces and punctuation. For stricter checks, add a custom keystroke or validation script in the phone field’s properties using patterns for the permitted phone-number formats.

Will the dynamic limit work in every PDF viewer?

Not necessarily. PDF viewers differ in their support for form JavaScript. Save the form and test it in the Acrobat or other PDF application your recipients will use.