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

Help with stopping my autodate fill script at certain dates.

New Here ,
Aug 14, 2017 Aug 14, 2017

Hi everyone.

Im very new to javascript but learning. Im making i time sheet for my employer and have a calender widget on the first day of the week so whoever needs to use it can click on that datefield and choose a date. I wrote a script (With some inspiration from around here) to fill out the rest of the dates of the week. So if someone chooses monday 08/14-2017, the rest of the dates gets filled out by the script.

I was asked if i could make it stop autofilling if a certain date is hit (We need to make them start a new timesheet at 2 dates each months , even if its midweek.) and im not sure where to go from here.

This is the script i put in the costum calculation scripts for the other days. So this code is for tuesday and for wednesday i just changed the d.setdate to +2 etc.

Any help on getting it to stop if i get the 20. and 31. of the month?

(function () { 

 

    // Get date from field 

    var v = getField("Dato").valueAsString; 

 

    // Convert string to date 

    var d = util.scand("dd/mm-yy", v); 

 

    // Add days 

    d.setDate(d.getDate() + 1); 

 

    // Populate this field with the result 

    if (v) { 

        event.value = util.printd("dd/mm-yy", d); 

    } else { 

        event.value = ""; 

    } 

 

})();

TOPICS
Acrobat SDK and JavaScript , Windows
231
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 ,
Aug 14, 2017 Aug 14, 2017

Change:

if (v) {

To:

if (v && d.getDate()!=20 && d.getDate()!=31) {

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
New Here ,
Aug 14, 2017 Aug 14, 2017
LATEST

Thanks alot! I was very close, haha. Helped a ton.

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