Skip to main content
Participant
April 24, 2017
Answered

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

  • April 24, 2017
  • 2 replies
  • 2031 views

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?

This topic has been closed for replies.
Correct answer Karl Heinz Kremer

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.

2 replies

Karl Heinz  Kremer
Community Expert
Karl Heinz KremerCommunity ExpertCorrect answer
Community Expert
April 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.

try67
Community Expert
Community Expert
April 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.

SGroholaAuthor
Participant
April 24, 2017

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!!