Skip to main content
brian704
Inspiring
November 14, 2016
Answered

error message when setting today's date in a field

  • November 14, 2016
  • 7 replies
  • 2483 views

I'm trying to get Acrobat to pre-populate a date field with today's date. I have placed the following code in the "Page Open" section:

var f = this.getField("Date");

f.value = util.printd("mm/dd/yyyy", new Date());

Date is the field name. The format matches the format for the field. When I open the document I get the following error:

"Invalid date/time: please ensure that the date/time exists. Field [Date] should match format mm/dd/yyyy"

The date appears in the field with the proper format. Any idea why I'm getting the error?

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer try67

Very strange. Try deleting the field, saving the file, and then re-creating it. If that doesn't help you will need to share the file with us for further help...

7 replies

brian704
brian704Author
Inspiring
November 14, 2016

I tried that but all I get in the field is a "0" - no error message though

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
November 14, 2016

Very strange. Try deleting the field, saving the file, and then re-creating it. If that doesn't help you will need to share the file with us for further help...

brian704
brian704Author
Inspiring
November 15, 2016

Deleting and re-creating it worked. Just one of those odd computer gremlins I guess

Thanks

try67
Community Expert
Community Expert
November 14, 2016

It's strange indeed... But if you only use a script to populate the value

of the field there's no real reason to use the date Format option. Try

setting it to None.