Copy link to clipboard
Copied
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?
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...
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
I tried that but all I get in the field is a "0" - no error message though
Copy link to clipboard
Copied
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...
Copy link to clipboard
Copied
Deleting and re-creating it worked. Just one of those odd computer gremlins I guess
Thanks
Copy link to clipboard
Copied
The script for this action is best placed as a document level script so it runs upon the opening of the PDF>
Copy link to clipboard
Copied
Yes - that's where I put it
Copy link to clipboard
Copied
Did close and reopen the PDF?
The action is only run when tha page is opened. This means you have to navigate to a differemt page and then come bsck to the page or close and reopen the PDF and page.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now