Copy link to clipboard
Copied
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?
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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!!
Copy link to clipboard
Copied
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.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more