Preserve Phone Number Formatting in Adobe Acrobat Form Fields
Question details
Format a phone number consistently when combining its value with text in another PDF form field.

- Product
- Adobe Acrobat PDF forms
- Device & OS
- not provided
- Scenario
- A calculated text field includes a phone number entered in another PDF form field.
- Observed behavior
- The phone number's displayed format may not carry over when its value is inserted into the destination field.
Open the PDF in a version of Adobe Acrobat that can edit form fields, and check the exact name of the phone number field. The example below expects a 10-digit phone number and a destination text field.
Format the phone number with an Acrobat calculation script
Use a custom calculation script when the destination field must combine a phone number with a sentence.
The script reads the source field as a string and applies the pattern 999 999-9999 before adding it to the destination field. Adjust the pattern and sentence to suit your form.
Open the PDF in Adobe Acrobat and select Tools > Prepare Form, or find Prepare a Form under All tools.
Open the phone number field's Properties and check its name on the General tab. The example uses Phone Number; replace that name in the script if yours is different.
Open the destination text field's Properties, select the Calculate tab, choose Custom calculation script, and click Edit. Enter: var f = this.getField("Phone Number"); var nFormat = util.printx("999 999-9999", f.valueAsString); if (f.value) event.value = "If you have any questions, please do not hesitate to call me at " + nFormat + "."; else event.value = "";
Confirm the script, close field Properties, and save the PDF. Enter a 10-digit number in Phone Number and move to another field to check the calculated sentence; clear the number to check that the destination field becomes blank.

Work with PDFs and Office documents in WPS Office
WPS Office is a free, lightweight Office alternative with a familiar interface for working with PDFs and common Office documents. It can help you move between existing files, but it does not replace Acrobat's custom form calculation scripting.

Frequently Asked Questions
Why does the phone number lose its display format in the combined field?
A field's display formatting may not carry over when its value is inserted into another field. In the destination field's Calculate script, read valueAsString and use util.printx to apply the desired pattern.
Where do I enter the calculation script in Acrobat?
In Prepare Form, open the destination text field's Properties. On the Calculate tab, select Custom calculation script and click Edit.
How do I change the phone number format?
Change the pattern in util.printx, such as replacing "999 999-9999" with "(999) 999-9999". Test the form with the number lengths and country codes your users will enter.
Will the calculated field work in every PDF viewer?
Not necessarily. PDF viewers differ in their support for Acrobat JavaScript and form calculations. Test the saved form in the viewer your recipients will use, and check whether JavaScript is enabled.




