Copy link to clipboard
Copied
I am creating a form the give dates they can use security authentication codes given to them
There are 28 day codes, 60 week codes and 5 year codes. I created a drop down box
with their selection (i.e., 28, 60, etc). Is there a way to create separate fields that give
the start and end date of each type selected?
Copy link to clipboard
Copied
The end date can be calculated based on the start date and that period, but what is the start date? The current date? A date the user enters? Something else?
Copy link to clipboard
Copied
Date entered by the user
Copy link to clipboard
Copied
Then you can use something like this as the custom calculation script of the end date field (adjust the field names, options and date format as needed):
var startDate = this.getField("StartDate").valueAsString;
var term = this.getField("Term").valueAsString;
if (startDate=="") event.value = "";
else {
var d = util.scand("mm/dd/yyyy", startDate);
if (term=="28 Days") d.setDate(d.getDate()+28);
else if (term=="60 Weeks") d.setDate(d.getDate()+(60*7));
else if (term=="5 Years") d.setFullYear(d.getFullYear()+5);
event.value = util.printd("mm/dd/yyyy", d);
}