PDF Editing Issues

Automatically Add the Current Time to an Adobe Acrobat Form Field

Chanuka GeekiyanageChanuka Geekiyanage Nov 19, 2026 869 views

Question details

Add the current time to one PDF form field when another field is clicked or filled in.

Automatically Add the Current Time to an Adobe Acrobat Form Field
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the form editor

Open the PDF in Adobe Acrobat and select Prepare a form from All tools.

2
Open field properties

Right-click the Name field, select Properties, and open the Actions tab.

3
Add a JavaScript action

Set Select Trigger to On Focus and Select Action to Run a JavaScript, then click Add.

4
Enter the script

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.

5
Save and test

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 When the Name Field Receives Focus
When the time updates: The script can overwrite the Time field if the Name field receives focus again while still empty. The field names in the script must match the names in the form.
Free Microsoft Office alternative

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.

Open PDF forms and enter a time manuallyCompatible with Microsoft Word, Excel, and PowerPoint formats, including DOCX, XLSX, and PPTXUse a familiar interface for everyday document workMove existing Office files into a lightweight workspace
microsoft office alternative - wps office

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.