Clear script generated data in a form field

Community Beginner ,
Feb 05, 2019 Feb 05, 2019

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

TOPICS
Acrobat SDK and JavaScript, Windows

Views

151

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct Answer

Most Valuable Participant , Feb 06, 2019 Feb 06, 2019
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 }

Likes

Translate

Translate
Most Valuable Participant ,
Feb 06, 2019 Feb 06, 2019

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

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 06, 2019 Feb 06, 2019

Copy link to clipboard

Copied

LATEST

That worked perfectly for my needs, Thank you for the help !!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines