• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

542

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

Community Expert , 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

}

Votes

Translate

Translate
Community Expert ,
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

}

Votes

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 !!

Votes

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