How to Show the Current Date and Time in a PDF Field on Mouse Up
Question details
The user wants to configure a PDF text field to automatically display the current date and time when clicked.

- Product
- PDF Editors
- Device & OS
- not provided
- Scenario
- Creating an interactive PDF form that captures the exact time a user interacts with a specific field.
- Observed behavior
- A custom JavaScript trigger is required to fetch the system time and insert it into the target field upon releasing the mouse button.
Ensure you are using a PDF editor that supports form creation and executing custom JavaScript, and switch your document to form editing mode.
Add JavaScript to the Field's Mouse Up Action
Use the built-in Acrobat JavaScript utility to fetch the current date and format it into the text field when triggered.
PDF forms support interactive elements through JavaScript. By binding a script to the 'Mouse Up' action, you guarantee the script executes the moment a user finishes clicking the field.
In your PDF form editor, right-click the target text field and select 'Properties' from the context menu.
Navigate to the 'Actions' tab within the Properties dialog. From the 'Select Trigger' dropdown, choose 'Mouse Up'.
From the 'Select Action' dropdown, choose 'Run a JavaScript', then click the 'Add' button.
In the JavaScript Editor window, paste the following code: event.target.value = util.printd("yyyy/mm/dd/HH:MM", new Date()); then click 'OK' and close the properties window.

Create and Manage Interactive PDF Forms with WPS Office
WPS Office provides a powerful PDF suite that allows you to view, fill, and manage interactive PDF forms with ease, ensuring high compatibility with standard PDF features.
- 1. Open your PDF Document: Launch WPS Office and open the PDF form you need to view or edit.
- 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to access interactive field tools and filling options.
- 3. Interact with the Fields: Click on the designated form fields to enter your data or trigger any interactive timestamps embedded in the document.
- 4. Save the Completed Form: Once your data and timestamps are filled, click 'Save' or 'Save As' to store the updated PDF on your local drive.

Frequently Asked Questions
Why does the date only update when I click the field?
Because the JavaScript is explicitly tied to the 'Mouse Up' trigger, it only executes when you perform a mouse click on that specific field. It does not act as a live, continuously ticking clock.
Can I format the time to a 12-hour AM/PM display?
Yes, you can modify the date format string in the JavaScript. Use 'h' for a 12-hour format and append 'tt' for the AM/PM indicator. For example: util.printd("yyyy/mm/dd h:MM tt", new Date());
Will this JavaScript work on mobile PDF readers?
Support for custom JavaScript varies across mobile PDF applications. While standard desktop PDF editors handle these scripts natively, many mobile readers do not fully support executing Acrobat JavaScript, which may prevent the date from auto-filling.
What is the difference between 'Mouse Up' and 'Mouse Down' in PDF forms?
'Mouse Down' triggers the moment the mouse button is pressed, while 'Mouse Up' triggers when the button is released. 'Mouse Up' is the standard best practice for interactive fields as it gives the user a fraction of a second to cancel the action by dragging the cursor away before releasing.




