Other PDF Issues

How to Calculate Full Names and Reformat Dates in PDF Forms

Khadija KhanKhadija Khan Oct 28, 2026 868 views

Question details

The user needs to automatically combine separate first and last name fields into a single full-name display and reformat a 6-digit date-of-birth (ddmmyy) into a new date format (dd.mm.20yy) elsewhere in the PDF.

How to Calculate Full Names and Reformat Dates in PDF Forms
Product
PDF Form Editors
Device & OS
not provided
Scenario
Creating or editing a fillable PDF form where user input must be reused, combined, and reformatted automatically to save time and prevent manual entry errors.
Observed behavior
The user wants to display the concatenated full name and the reformatted date in secondary fields without requiring the person filling out the form to enter the information multiple times.
Before you start

Ensure your PDF editing software supports form field properties and custom JavaScript calculations. Take note of the exact field names (e.g., 'firstname', 'lastname', 'dateofbirth') used in your document before writing the scripts.

Solution 1Recommended

Use Custom Calculation Scripts for PDF Form Fields

Apply JavaScript to the target output fields to automatically pull, format, and display data from the source fields.

By utilizing custom JavaScript in your PDF editor's form field properties, you can extract values from source fields, manipulate them (like concatenating strings or adding punctuation), and output the result automatically.

1
Open target field properties

Enter Form Editing mode in your PDF editor. Double-click the target field where you want the combined full name to appear to open its Properties window.

2
Add name calculation script

Navigate to the 'Calculate' tab, select 'Custom calculation script', click 'Edit', and enter the following code: var firstName = this.getField('firstname').valueAsString; var lastName = this.getField('lastname').valueAsString; event.value = firstName && lastName ? lastName + ', ' + firstName : '';

3
Add date calculation script

Open the Properties for your target date field, go to the 'Calculate' tab, select custom script, and enter: var dob = this.getField('dateofbirth').valueAsString; event.value = dob ? dob.substring(0,2) + '.' + dob.substring(2,4) + '.20' + dob.substring(4) : '';

4
Set fields to read-only

Go to the 'General' tab in the Properties window for both target output fields and check the 'Read-Only' box. This ensures users cannot manually overwrite the auto-calculated results.

Use Custom Calculation Scripts for PDF Form Fields
Field Names Must Match: Ensure that 'firstname', 'lastname', and 'dateofbirth' in the scripts perfectly match the actual names of your original input fields, as JavaScript is case-sensitive.
Advanced PDF Form Editing

Easily Manage and Edit PDF Forms with WPS Office

WPS Office provides a comprehensive PDF editor that allows you to interact with fillable forms, edit text, manage pages, and securely handle document data without hassle.

  1. 1. Open your PDF file: Launch WPS Office and open the PDF document that contains the fillable forms.
  2. 2. Access the Form tools: Navigate to the 'Form' or 'Fill & Sign' tab on the top ribbon to view and manage fillable fields, text boxes, and interactive elements.
  3. 3. Fill and save the document: Click into the form fields to enter your data directly, then click 'Save' or press Ctrl+S to retain all entered information.
Advanced PDF form editing and filling capabilities.Seamlessly compatible with standard Adobe Acrobat PDF formats.Lightweight and intuitive interface for quick document management.Free tools to insert text boxes, signatures, and annotations.
microsoft office alternative - wps office

Frequently Asked Questions

Why is my custom calculation script not working in the PDF?

Double-check that the field names referenced in your JavaScript (like this.getField('firstname')) exactly match the names of your form fields. Because JavaScript is case-sensitive, 'FirstName' and 'firstname' are treated as two completely different fields.

Can I format the date differently, like mm/dd/yyyy?

Yes, you can modify the substrings in the JavaScript calculation to fit any format. For example, to change ddmmyy to mm/dd/yyyy, you would rearrange the script to extract the month substring first, followed by a slash, the day substring, and then the year.

Why should I make the calculated PDF fields read-only?

Setting the output fields to read-only prevents the person filling out the form from accidentally typing over the auto-calculated full name or reformatted date. This ensures the output data always remains perfectly consistent with their original inputs.