How to Automatically Populate an Expiration Date from a Manually Entered Date in Acrobat
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.

- 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.
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.
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.
Open your PDF document and access the 'Prepare Form' tool to view all interactive fields.
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.
Right-click the 'ExpirationDate' field and select Properties. Go to the Calculate tab, select 'Custom calculation script', and click the 'Edit' button.
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);

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. Open WPS PDF: Launch WPS Office and open your PDF document using the built-in WPS PDF editor.
- 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to reveal the interactive form creation tools.
- 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.

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.




