PDF Editing Issues

How to Automatically Fill Date When a PDF Name Field is Completed

Amos GikundaAmos Gikunda Nov 3, 2026 869 views

Question details

The user wants a date field in a PDF sign-in form to automatically populate with the current date and time when the adjacent attendee name field is filled out.

How to Automatically Fill a Date When a PDF Name Field is Completed
Product
PDF Forms
Device & OS
not provided
Scenario
Creating an interactive sign-in form that requires automatic timestamping for attendee entries to save time and ensure accurate record-keeping.
Observed behavior
The goal is to trigger an automatic date and time insertion into a specific date field whenever the corresponding name field is no longer empty.
Before you start

Ensure you are using a PDF editor that supports JavaScript execution and advanced form field properties. You will need to know the exact field names for both your name input and date output fields before applying the script.

Solution 1Recommended

Use a Custom Validation Script to Auto-Fill the Date

By adding a short JavaScript snippet to the name field's validation settings, the date field will automatically update with the current date and time when a name is entered.

This method uses JavaScript to detect when the name field is filled and immediately outputs the system date and time into the adjacent date field. If the name is deleted, the script is designed to clear the date field as well.

1
Open Field Properties

Open your PDF form in edit mode. Right-click the name field (for example, the field named 'name1') and select 'Properties' from the context menu.

2
Navigate to the Validate Tab

In the Properties dialog box, click on the 'Validate' tab to configure the field's validation behavior.

3
Enter the Custom Script

Select the 'Run custom validation script' radio button, then click the 'Edit' button. Paste the following code into the window: this.getField("date1").value = (event.value == "") ? "" : util.printd("mm/dd/yyyy HH:MM", new Date());

4
Save and Test

Click 'OK' to save the script and close the properties window. Switch to the form preview or viewing mode, type a name into the field, and press Enter to see the date field auto-populate.

5
Repeat for Multiple Fields

Repeat this process for any other name/date field pairs on your sign-in sheet, making sure to update the target field name in the script (e.g., changing 'date1' to 'date2').

Use a Custom Validation Script to Auto-Fill the Date
Exact Field Names Required: JavaScript is case-sensitive. Make sure the name inside getField("date1") perfectly matches the actual name of your target date field, otherwise the script will not work.
Edit PDF Forms Easily

Create and Manage PDF Forms with WPS Office

WPS PDF provides a comprehensive set of tools for creating interactive forms, adding text fields, and managing advanced document properties efficiently without complex setup.

  1. 1. Open PDF Document: Launch WPS Office and open your existing PDF form or create a new blank document.
  2. 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to access the interactive form editing tools.
  3. 3. Insert Form Fields: Use the 'Text Field' option to insert input boxes for your names and dates on the document.
  4. 4. Configure Properties: Right-click any newly created field, select 'Properties,' and set up your formatting, validation scripts, or calculations.
Fully compatible with Adobe PDF forms and JavaScript execution.Easily add, edit, and manage interactive form fields like text boxes, dates, and checkboxes.Lightweight software with an intuitive, user-friendly interface for seamless document management.
microsoft office alternative - wps office

Frequently Asked Questions

Can I change the date format in the custom validation script?

Yes, you can easily modify the "mm/dd/yyyy HH:MM" portion of the script. For example, use "dd/mm/yyyy" for a standard European format, or remove "HH:MM" if you only need the date without the specific time.

Why isn't the date field updating immediately after I type a name?

Validation scripts typically trigger when you exit or 'commit' the field. You need to press the Enter key, press Tab, or click outside the name field to trigger the script. Also, double-check that your target field name exactly matches the one written in the script.

Will this auto-fill script work on mobile PDF viewers?

Most basic mobile PDF readers and web browser viewers do not fully support JavaScript form calculations. For the auto-fill feature to function reliably, users should fill out the PDF using a robust desktop application like WPS Office or Adobe Acrobat.

How do I clear the date if the user accidentally types a name and then deletes it?

The provided script handles this automatically. The condition (event.value == "") ? "" acts as an IF statement, ensuring that if the name field becomes empty, the date field will also be cleared simultaneously.