Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

error message when setting today's date in a field

Enthusiast ,
Nov 14, 2016 Nov 14, 2016

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?

TOPICS
Acrobat SDK and JavaScript
2.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 14, 2016 Nov 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...

Translate
Community Expert ,
Nov 14, 2016 Nov 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 14, 2016 Nov 14, 2016

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 14, 2016 Nov 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...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 15, 2016 Nov 15, 2016

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

Thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 15, 2016 Nov 15, 2016

The script for this action is best placed as a document level script so it runs upon the opening of the PDF>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 15, 2016 Nov 15, 2016
LATEST

Yes - that's where I put it

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 14, 2016 Nov 14, 2016

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines