Copy link to clipboard
Copied
Hi,
Esteemed users of Acrobat Forms. I am looking for some help!
I am using the following Javascript to auto populate Date field. Intent is that a user when first time opens the form, this date field will be auto populated and will stay same.
var currentTime = new Date();
var month – currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
var rTime = day + “/” + month + “/” + year;
this.getField(“DateReceived”).value = rTime;
I tried all the following three options for entering Javascript (one at a time) and in all cases I am getting the same error message: “Error: SyntaxError: Illegal character at line 3.”
Since I am not a Java programmer, I was wondering if somebody could please help resolve this?
Copy link to clipboard
Copied
Try this:
var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
var rTime = day + "/" + month + "/" + year;
this.getField("DateReceived").value = rTime;
Copy link to clipboard
Copied
Try this:
var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
var rTime = day + "/" + month + "/" + year;
this.getField("DateReceived").value = rTime;
Copy link to clipboard
Copied
Thanks a lot. That works! [Just found out waht I was ding wrong.]
Copy link to clipboard
Copied
The error message is caused by the curly quotes you're using. You must only use straight quotes (single or double) in your code for strings.
Copy link to clipboard
Copied
Thanks a lot for pointing out this. I will note it for future reference.