Automatically Add the Current Time to an Adobe Acrobat Form Field
Question details
Add the current time to one PDF form field when another field is clicked or filled in.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A PDF form contains a Name field and a separate Time field that should receive a timestamp during data entry.
- Observed behavior
- The Time field should display the current time when the selected field event occurs.
Open the PDF in Adobe Acrobat and confirm that the form has text fields named Name and Time. You need access to Acrobat's form editing tools and a PDF viewer that supports Acrobat JavaScript to test the action.
Add a Timestamp When the Name Field Receives Focus
Use an On Focus action to record the time when someone enters an empty Name field.
Open the PDF in Adobe Acrobat and select Prepare a form from All tools.
Right-click the Name field, select Properties, and open the Actions tab.
Set Select Trigger to On Focus and Select Action to Run a JavaScript, then click Add.
In the JavaScript editor, enter: var f = this.getField("Name"); var g = this.getField("Time"); if (f.valueAsString == "") g.value = util.printd("HH:MM", new Date()); Click OK and close the field properties.
Save the PDF, exit form editing, and click the empty Name field. The Time field should show the current time in 24-hour format.

Add a Timestamp After the Name Field Is Filled In
Use an On Blur action to record the time when the user leaves a nonempty Name field.
Work With PDF Forms and Office Files in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with PDF and Office files. It can help you fill in a time manually, but it does not replace the Acrobat JavaScript setup described above.

Frequently Asked Questions
Why does the timestamp not appear when I click the Name field?
In Prepare a form, check that the action is attached to the Name field with the On Focus trigger and that the form fields are named exactly Name and Time. Also test in a PDF viewer that supports Acrobat JavaScript.
How can I add the time only after entering a name?
In the Name field's Properties > Actions tab, use an On Blur JavaScript action that checks whether the Name field is nonempty before setting the Time field.
Will the timestamp keep updating as time passes?
No. The script writes the current time when the selected field event occurs; it is not a running clock.
How do I prevent the time from being overwritten?
Add a check that the Time field is empty before assigning a value, as shown in the On Blur solution. This preserves an existing timestamp when the event occurs again.




