Today’s Date On Acrobat Form Date Field

Fill Acrobat Form date field with today’s date only if field is empty:

The goal is for an Acrobat form to fill a date field (“MeetingDate”) with Today’s date when the user opens it. If the user saves the form as is and opens it a few days later, the old date should still be there, not replaced by the current date. If the user changes date in the field, that date should be saved and should not be replaced when the form is opened later.

Here is a document javascript to do this:

var f = this.getField("wells_datefield");
if (!f.value) f.value = util.printd ("m/d/yyyy", new Date());
Save your form and open it, and the date should pop right in there.
When making the document javascript, remember to not put it inside a function.

One way of doing that is the following. In the Acrobat menu:

  1. Advanced->Document Processing->Document Javascripts…
  2. In the dialog that pops up, enter a Script Name (for instance “populate_date”) and click Add…
  3. In the script dialog that pops up: REMOVE everything (“function populate_date(){}”) and paste in the script above.
  4. Click ok, then Close.
  5. Save the form, close it and reopen it.
  6. There is no step 6! :>