Other PDF Issues

How to Set an Expiration Date and Reminder in a PDF Form

Khadija KhanKhadija Khan Nov 5, 2026 870 views

Question details

The user wants to automatically calculate an expiration date 60 days after sending, display it in the PDF form, and show a reminder alert when the recipient opens the file.

How to Set an Expiration Date and Reminder in a PDF Form
Product
PDF Editor
Device & OS
not provided
Scenario
Creating an interactive PDF form that requires a time-sensitive response from recipients.
Observed behavior
The current JavaScript code incorrectly changes the year instead of adding days because it uses setYear() combined with getDay().
Before you start

Ensure your PDF editor supports JavaScript and that you have permission to edit document-level scripts and interactive form fields.

Solution 1Recommended

Use Correct JavaScript to Calculate the 60-Day Expiration Date

Fix the flawed JavaScript logic by replacing setYear() with setDate() to accurately add 60 days to the current date and display it in your target field.

The problem with using ExpDate.setYear(ExpDate.getDay() + 60) is that getDay() returns the day of the week (0-6), and setYear() modifies the year. This combination results in nonsensical dates instead of shifting the day forward by 60 days.

1
Access Document Scripts

Open your PDF editor, navigate to the Form or Tools tab, and select Document JavaScripts or the specific form field properties where the calculation should occur.

2
Create the Calculation Script

Define a new Date object for the current date. Use the correct method to add 60 days: var ExpDate = new Date(); ExpDate.setDate(ExpDate.getDate() + 60);

3
Assign the Result to the Form Field

Format the resulting date string into your preferred layout (e.g., mm/dd/yyyy) and assign it to the value property of your designated due-date text field.

Use Correct JavaScript to Calculate the 60-Day Expiration Date
Target Field Name: Make sure the destination field name in your script exactly matches the name of the text field created in the PDF form.
Powerful PDF Editor

Easily Create Interactive Forms in WPS PDF

WPS PDF provides robust tools for creating interactive PDF forms, adding calculating text fields, and managing document actions efficiently.

  1. 1. Open WPS PDF: Launch WPS Office and open your PDF document using the built-in PDF editor.
  2. 2. Navigate to Form Tools: Click on the 'Form' tab at the top menu to access tools for adding various interactive form elements.
  3. 3. Customize Field Properties: Right-click your newly added form fields to access properties, configure format settings, and specify required actions.
Fully supports inserting text fields, checkboxes, and interactive buttonsHighly compatible with standard Adobe Acrobat PDF formats and featuresLightweight application with a clean, user-friendly editing interface
microsoft office alternative - wps office

Frequently Asked Questions

Why is my JavaScript date calculation changing the year instead of days?

Using setYear() modifies the year of your Date object. Combining it with getDay(), which only returns the day of the week (0-6), causes the script to set an invalid year. To add days, you must use setDate() and getDate().

Will the reminder pop-up work on all PDF readers?

Standard JavaScript alerts like app.alert() work on most major desktop PDF readers (including WPS PDF and Acrobat). However, some mobile PDF apps or basic web browser viewers may ignore JavaScript actions completely.

Can I set the expiration date to be based on a user input date instead of the current date?

Yes. You can retrieve the value of a user-filled date field, convert it into a valid JavaScript Date object, and then use the setDate() method to add your desired number of days before outputting the result.