We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.
I have 2 fields, we'll call "Date1" and "Date2". I want Date2 to automatically populate with the same date as Date1, but I want Date1 to have the format "DDMMYYYY" and Date2 to have "dd-mmm-yyyy". If I simply make the fields the same name, they will have the same date format.
I tried using the following in the custom calculation script for Date2, but it just ends up blank:
var dateVar = this.getField("Date1").valueAsDate; if (dateVar != "") event.value = dateVar; else event.value = "";
I also tried using "valueAsString", but then I get this error:
"Invalid date/time: please ensure that the date/time exists. Field [ Date2 ] should match format dd-mmm-yyyy"
Hope it will help
You mean "Date1" have format "ddmmyyyy" not "DDMMYYYY"?
As "Validation" script of "Date1" field use this:
var f = this.getField("Date2");
if (event.value == "") f.value = "";
var date = util.scand("ddmmyyyy", event.value);
f.value = util.printd("dd-mmm-yyyy", date);}
What's the point of this line?
I used it for something else and forgot to delete, Fixed, thanks for pointing out 🙂
right again! Thanks for the help!