How to Create a Dynamic Year Range in an Acrobat PDF Form
Question details
The user needs a PDF form to automatically generate and display a year range calculated from the year the application is completed, rather than using a static date.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating advanced PDF forms that require automatic date or year range calculations based on the specific time of form filling.
- Observed behavior
- Standard date formats in PDF form fields do not support calculated offsets or dynamic year ranges, requiring a script-based workaround.
Ensure you have access to a PDF editor that supports JavaScript form properties, such as Adobe Acrobat Pro or WPS PDF, and familiarize yourself with basic text field settings.
Use Custom Calculation Scripts for Automatic Generation
Since standard date formats cannot calculate dynamic offsets, use a custom JavaScript in the calculation tab to automatically pull the completion year and build the range string.
PDF standard date properties restrict fields to simple calendar dates. To compute a dynamic year range (e.g., 2023-2024), you must bypass the standard date formats entirely and apply a custom calculation script to a standard text field.
Open your PDF form in edit mode and double-click the target text field where you want the year range to appear to open its Properties dialog.
Navigate to the 'Format' tab and ensure the format category is set to 'None' rather than 'Date'.
Switch to the 'Calculate' tab and select 'Custom calculation script'. Click the 'Edit' button to open the JavaScript editor.
Enter a script that retrieves the current year, adds your offset, and assigns it to the field value. For example: var currentYear = new Date().getFullYear(); event.value = currentYear + ' - ' + (currentYear + 1);

Apply Custom Format and Validate Scripts for Manual Entry
If users need to manually enter a base year but you want the field to specifically validate the entry or automatically reformat it as a range, use Custom Format and Validate scripts.
Use WPS PDF to Edit and Manage Interactive Forms
WPS Office provides a comprehensive PDF editor that allows you to easily create, fill, and manage interactive PDF forms. Its intuitive interface simplifies advanced document formatting for all users.
- 1. Open Your PDF: Launch WPS Office and open the PDF form you need to edit.
- 2. Access Form Tools: Navigate to the 'Form' tab located on the top ribbon to access interactive form tools.
- 3. Add a Text Field: Click to insert a 'Text Field' into your document and double-click it to configure its properties and formatting.
- 4. Save and Share: Once your dynamic fields are set up, save the customized PDF form and share it with your users.

Frequently Asked Questions
Can I use standard date formats for year ranges in PDF forms?
No, standard PDF date formats are designed strictly to select and display a single calendar date. To compute and display year ranges, you must use text fields with custom scripts.
What JavaScript code gets the current year in a PDF?
You can use 'new Date().getFullYear();' within a custom calculation script to retrieve the current four-digit year from the user's system.
Why isn't my PDF calculation script updating automatically?
Calculation scripts trigger based on the document's field calculation order or when other fields are modified. Check your form properties to ensure the field calculation order is sequenced correctly.




