PDF Editing Issues

How to Automatically Populate an Expiration Date from a Manually Entered Date in Acrobat

Muhammad TalhaMuhammad Talha Nov 10, 2026 869 views

Question details

The user wants to configure a PDF form to let users manually enter an issue date, and then automatically calculate and display an expiration date exactly one year later.

How to Automatically Populate an Expiration Date from a Manually Entered Date in Acrobat PDF
Product
Adobe Acrobat
Device & OS
not provided
Scenario
Creating an interactive PDF form with automated date calculations using JavaScript.
Observed behavior
The original script overwrites the manually entered issue date value because it is placed in the wrong field's calculation script, and it contains date-formatting and syntax errors.
Before you start

Ensure you have access to the 'Prepare Form' tool in your PDF editor and that your document already contains separate text fields for both the Issue Date and the Expiration Date.

Solution 1Recommended

Add a Custom Calculation Script to the Expiration Date Field

Fix the issue by moving the calculation script out of the Issue Date field and placing it specifically in the Expiration Date field with corrected JavaScript syntax.

A common mistake when automating PDF form calculations is placing the script in the field meant for manual entry. If a script is placed in the 'Custom Calculation Script' of the IssueDate field, it will execute and overwrite anything the user tries to type manually.

To solve this, the script must be applied to the target field (ExpirationDate). The script will read the value from the IssueDate field, calculate the new date by adding one year, and then format it correctly.

1
Open Form Editing Mode

Open your PDF document and access the 'Prepare Form' tool to view all interactive fields.

2
Clear the IssueDate Field

Right-click the 'IssueDate' field and select Properties. Navigate to the Calculate tab and ensure the value is set to 'Value is not calculated'. This prevents manual inputs from being overwritten.

3
Edit the ExpirationDate Field

Right-click the 'ExpirationDate' field and select Properties. Go to the Calculate tab, select 'Custom calculation script', and click the 'Edit' button.

4
Enter the Correct JavaScript

Input a script that reads the issue date, validates it, adds a year, and formats the output. Ensure you use proper syntax, such as an equals sign after variable declarations and four 'y's in the format string. For example: util.printd("mm/dd/yyyy", newDateObject);

Add a Custom Calculation Script to the Expiration Date Field
Script Placement: Always remember that calculation scripts should only be placed in the field where the result needs to be displayed, never in the field where the user inputs the initial data.

Create and Manage Interactive PDF Forms with WPS Office

WPS PDF provides a comprehensive set of form-building tools, allowing you to easily add text fields, configure properties, and manage fillable documents without needing expensive PDF software.

  1. 1. Open WPS PDF: Launch WPS Office and open your PDF document using the built-in WPS PDF editor.
  2. 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to reveal the interactive form creation tools.
  3. 3. Add and Configure Fields: Click 'Text Field' to draw your Issue Date and Expiration Date boxes, then double-click them to access their properties and format settings.
Easily create fillable PDF forms with text fields, checkboxes, and drop-down menusHighly compatible with Adobe Acrobat PDF formats and form structuresLightweight and user-friendly interface for seamless document editingFree to use for basic PDF reading, form filling, and editing tasks
microsoft office alternative - wps office

Frequently Asked Questions

Why does my manually entered date disappear as soon as I click away?

This happens when a custom calculation script is accidentally placed in the properties of the entry field itself. The field runs the script and overwrites your manual input. You must remove the calculation script from the input field and place it in the destination (result) field.

What is the correct date format code for PDF JavaScript?

When formatting dates in PDF JavaScript using util.printd, the standard format for a four-digit year is "mm/dd/yyyy". Make sure to use four 'y' characters to avoid formatting errors.

Can I automate adding 30 days instead of a full year?

Yes. Instead of using the setFullYear() method in your JavaScript, you can use the setDate() method. You would get the current day using getDate() and simply add 30 to it before formatting the output.