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

Yesterday date, but want manual exception

Community Beginner ,
Mar 29, 2016 Mar 29, 2016

I have a form in which it shows yesterday's date when you open it, unless it is a Monday then it shows Friday's date. The date is separated in 3, so I have ScanDate_month, Scandate_year, and ScanDate_day.

When the form opens, a hidden field (Today) sets today's date and another sets the day of the week (WeekDay).

var m = this.getField("ScanDate_month");

var y = this.getField("ScanDate_year");

var fld = this.getField("ScanDate_day");

var d1 = new Date();

var num = d1.valueOf();

if(this.getField("WeekDay").value == "Mon")

{

num += -(1000 * 60 * 60 * 24 * 3);

}

else

{

num += -(1000 * 60 * 60 * 24);

}

m.value = util.printd ("mm", new Date(num));

fld.value = util.printd ("dd", new Date(num));

y.value = util.printd ("yyyy", new Date(num));

I would like to add some exceptions for Holidays.

For example, if today's date is 03/29/2016, instead of showing 03/28/2016 it would show 03/24/2016 because Friday and Monday were Holidays.

I realize that I will need to add each Holiday manually in the script, but that would be fine.

So I used else if, but it doesn't accept my script saying there is an error after the first exception

if(this.getField("WeekDay").value == "Mon")

{num += -(1000 * 60 * 60 * 24 * 3);}

else if

((this.getField("WeekDay").value == "Tue") || (this.getField("WeekDay").value == "Wed") || (this.getField("WeekDay").value == "Thu") || (this.getField("WeekDay").value == "Fri"))

{num += -(1000 * 60 * 60 * 24);}

else if

(this.getField("Today").value == "03/29/2016");

{num += -(1000 * 60 * 60 * 24 * 5);}

else if

(this.getField("Today").value == "05/24/2016");

{num += -(1000 * 60 * 60 * 24 * 4);}

else if

(this.getField("Today").value == "07/04/2016");

{num += -(1000 * 60 * 60 * 24 * 4);}

Can someone help me figure out what is the error after the first exception?

TOPICS
Acrobat SDK and JavaScript
520
Translate
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

LEGEND , Mar 29, 2016 Mar 29, 2016

Get rid of the semicolons at the end of lines like the following:

  1. (this.getField("Today").value == "03/29/2016");
Translate
LEGEND ,
Mar 29, 2016 Mar 29, 2016

Get rid of the semicolons at the end of lines like the following:

  1. (this.getField("Today").value == "03/29/2016");
Translate
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 ,
Mar 29, 2016 Mar 29, 2016
LATEST

That was a quick fix. Thanks to you too Try67.

Translate
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 Expert ,
Mar 29, 2016 Mar 29, 2016

Remove the semi-colons after the if statements.

Translate
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