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

Error message with month custom code "mmmm" - using Adobe Acrobat Pro

New Here ,
Apr 24, 2017 Apr 24, 2017

I have set up a form, and I have used javascript in other pdf forms for the date field, with no problem. 

In this pdf form, the date is broken out as " of the ___ day of _(Month)__, 20 __.  I set up a custom date format for each field.

Day - custom format "dd"

Month - custom format "mmmm"

Year - custom format "yy"

On the Page Properties Actions, I have set up to "Run a JavaScript":

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

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

var g=this.getField("Month");

g.value=util.printd("mmmm", new Date());

var h=this.getField("Year"); h.value=util.printd("yyyy", new date());

I keep getting an error message though "Invalid date/time: please ensure that the date/time exists.  Field [Month] should match format mmmm"

I'm not sure why I keep getting the error message.  Can anyone help?

TOPICS
Acrobat SDK and JavaScript , Windows
2.1K
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 , Apr 24, 2017 Apr 24, 2017

There is one problem in your code: In the last line, the "date" needs to be with a capital "D", just like in the previous line.

Do you have a field format set for the month field? If so, that is not necessary because you are setting the contents programmatically, and therefore it's not necessary to have the field validate any user input. Remove any formatting form the field in question and make it read-only. That should fix your problem.

Translate
Community Expert ,
Apr 24, 2017 Apr 24, 2017

You should remove the Format options for these fields. If they have a

calculated value then there's no need for it.

The issue is that just a month's name is not sufficient to create a

complete Date object, which is what the built-in Format code is trying to

do.

It also won't work if you manually enter "April" into that field. You'll

get the same error message.

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
New Here ,
Apr 24, 2017 Apr 24, 2017
LATEST

Thanks so much for all the help.... both answers are correct, but it would only let me tag one of them.

Once I removed the formatting from the field itself, and left the code, the day, month and year all dropped in. 

  Thanks again!!

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 ,
Apr 24, 2017 Apr 24, 2017

There is one problem in your code: In the last line, the "date" needs to be with a capital "D", just like in the previous line.

Do you have a field format set for the month field? If so, that is not necessary because you are setting the contents programmatically, and therefore it's not necessary to have the field validate any user input. Remove any formatting form the field in question and make it read-only. That should fix your problem.

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