Copy link to clipboard
Copied
I have a form that I am creating that has a "Clear Form" button on it that clears all of the form fields. For the most part, this works except for three fields that calculate a date based on a script. The three fields I am having problems are selected to be part of the "clear form" action.
What I would like help with is with is to either to modify the script to return a blank output if there is nothing in the input field or for the "clear form" button too clear everything.
The script I am using is as follows
var sDate = this.getField("InterviewComplete_af_date").value; // get date string
var oDate = util.scand("yyyy/mm/dd", sDate); // convert to object
var nDay = 1000 * 60 * 60 * 24; // define 1 day in milliseconds
var nDate = oDate.getTime() + (5 * nDay); // add 5 days as milliseconds
oDate = new Date(nDate); // convert milliseconds to date object
event.value = util.printd("yyyy/mm/dd", oDate); // format result
Change it to:
var sDate = this.getField("InterviewComplete_af_date").valueAsString; // get date string
if (sDate=="") event.value = "";
else {
var oDate = util.scand("yyyy/mm/dd", sDate); // convert to object
var nDay = 1000 * 60 * 60 * 24; // define 1 day in milliseconds
var nDate = oDate.getTime() + (5 * nDay); // add 5 days as milliseconds
oDate = new Date(nDate); // convert milliseconds to date object
event.value = util.printd("yyyy/mm/dd", oDate); // format result
}
Copy link to clipboard
Copied
Change it to:
var sDate = this.getField("InterviewComplete_af_date").valueAsString; // get date string
if (sDate=="") event.value = "";
else {
var oDate = util.scand("yyyy/mm/dd", sDate); // convert to object
var nDay = 1000 * 60 * 60 * 24; // define 1 day in milliseconds
var nDate = oDate.getTime() + (5 * nDay); // add 5 days as milliseconds
oDate = new Date(nDate); // convert milliseconds to date object
event.value = util.printd("yyyy/mm/dd", oDate); // format result
}
Copy link to clipboard
Copied
That worked perfectly for my needs, Thank you for the help !!