How to Set an Expiration Date and Reminder in a PDF Form
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.

- 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().
Ensure your PDF editor supports JavaScript and that you have permission to edit document-level scripts and interactive form fields.
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.
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.
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);
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.

Configure a Reminder Pop-up on Document Open
Set up a Document Open action to trigger a JavaScript alert message whenever the recipient opens the PDF.
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. Open WPS PDF: Launch WPS Office and open your PDF document using the built-in PDF editor.
- 2. Navigate to Form Tools: Click on the 'Form' tab at the top menu to access tools for adding various interactive form elements.
- 3. Customize Field Properties: Right-click your newly added form fields to access properties, configure format settings, and specify required actions.

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.




