Copy link to clipboard
Copied
Hi there,
I'm looking to create a field that will autopopulate a date that is two weeks out from today's date. I've already created a field that autopopulates today's date.
In my form, the today's date field is named "Today", and the field that I require assistance with is named "Start Date". In other words, I would like the form's start date to always be 2 weeks from today's date.
Any support would be greatly appreciated!
Thanks 🙂
Copy link to clipboard
Copied
As 'Validate' script of "Today" field, use this: (set date format to whatever you need)
if (event.value == "")
this.getField("Start Date").value = "";
else{
var today = util.scand("mm/dd/yyyy", event.value);
var startDate = new Date(today);
startDate.setDate(today.getDate() + 14);
this.getField("Start Date").value = util.printd("mm/dd/yyyy", startDate);}
Copy link to clipboard
Copied
As 'Validate' script of "Today" field, use this: (set date format to whatever you need)
if (event.value == "")
this.getField("Start Date").value = "";
else{
var today = util.scand("mm/dd/yyyy", event.value);
var startDate = new Date(today);
startDate.setDate(today.getDate() + 14);
this.getField("Start Date").value = util.printd("mm/dd/yyyy", startDate);}
Copy link to clipboard
Copied
Hi Nesa,
Thanks for the quick response! I added your suggested script to the 'properties' > 'validate' tab of the 'today' field, however the Start Date field is still not auto populating a date. Any ideas why this might be happening? Thanks!
Copy link to clipboard
Copied
It now seems to be working. Thanks again for your help!
Copy link to clipboard
Copied
Hi @Nesa Nurani - how would I code this if I wanted to insert it in a Document Level Script?
Copy link to clipboard
Copied
Depends, are you trying to do the same thing just from document level, or use it in multiple fields?
Copy link to clipboard
Copied
@Nesa Nurani Same thing just from document level. I want to ensure the script is run every time the document is opened.
Copy link to clipboard
Copied
Try this:
if (this.getField("Today").valueAsString == "")
this.getField("Start Date").value = "";
else{
var today = util.scand("mm/dd/yyyy", this.getField("Today").valueAsString);
var startDate = new Date(today);
startDate.setDate(today.getDate() + 14);
this.getField("Start Date").value = util.printd("mm/dd/yyyy", startDate);}
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more