PDF Editing Issues

How to Automatically Add Text Before and After PDF Form Input

Olivia MillerOlivia Miller Nov 3, 2026 869 views

Question details

The user needs to automatically prepend and append fixed text or characters (such as quotation marks) to the text entered by a user in a PDF form field.

How to Automatically Add Text Before and After PDF Form Input
Product
PDF Forms
Device & OS
not provided
Scenario
Designing an interactive PDF form where specific formatting or surrounding text is required automatically upon user data entry.
Observed behavior
The form field needs to dynamically update its value to enclose the user's raw input within predetermined characters or strings without destroying the original editable input.
Before you start

Ensure you are using a PDF editor that supports form field properties and custom JavaScript execution, as basic PDF readers cannot run calculation scripts.

Solution 1Recommended

Apply a Custom JavaScript Calculation to the Text Field

Use a custom JavaScript calculation to automatically combine your fixed text with the entered value in the PDF form field.

To prevent the script from duplicating the fixed text every time the user edits the field, it is highly recommended to use two separate fields: a visible source field for user input, and a hidden or read-only calculation field to display the formatted text.

1
Create the input field

Add a standard text field to your PDF form where the user will type their data. Note the exact name of this field (e.g., 'InputField').

2
Create the destination field

Add a second text field where the formatted text will appear. Right-click this field and select 'Properties'.

3
Set up the calculation

In the Properties dialog, navigate to the 'Calculate' tab.

4
Add the custom script

Select the 'Custom calculation script' option, click 'Edit', and enter the following script: event.value = '"' + this.getField('InputField').value + '"'; (Replace 'InputField' with your actual source field name). Click 'OK' to save.

Keep Original Input Editable: Using a separate source field ensures the original user input remains available and easy to edit without the automatically added text interfering with their cursor.
Powerful PDF Editor

Edit and Fill PDF Forms Seamlessly with WPS Office

WPS Office provides a comprehensive PDF toolkit to edit, fill, and manage PDF forms effortlessly. Easily interact with document fields and enjoy full compatibility with standard PDF formats.

  1. 1. Launch WPS PDF: Open WPS Office and click on 'PDF' to launch the built-in PDF editor.
  2. 2. Open the Form: Import or drag-and-drop your interactive PDF form document into the workspace.
  3. 3. Fill the Fields: Use the 'Form' tab tools to easily interact with text fields, checkboxes, and dropdowns.
  4. 4. Save and Export: Once completed, securely save your PDF or export it to share with others.
Easily fill interactive PDF forms without advanced setupEdit text, images, and form elements in existing PDFsHigh compatibility with Adobe Acrobat PDF formatsLightweight, fast PDF rendering with a familiar interface
microsoft office alternative - wps office

Frequently Asked Questions

Why does the fixed text duplicate when I edit the field directly?

If you apply the custom calculation script directly to the input field, the script may run recursively, continually appending the text every time the field updates. This is why it is recommended to use a separate source field for user input and a different field for the calculated display.

Can I add text strings other than quotation marks?

Yes. You can replace the quotation marks in the script with any desired text. For example, to add a prefix and a suffix, use: event.value = 'Prefix ' + this.getField('FieldName').value + ' Suffix';

Will this script work on mobile PDF readers?

JavaScript support varies significantly on mobile devices. While advanced desktop PDF editors fully support these form calculations, many basic or default mobile PDF viewers may ignore the custom scripts.