Putting a condition on a date to hide it

New Here ,
Feb 02, 2021 Feb 02, 2021

Copy link to clipboard

Copied

Please excuse my complete lack of knowledge when it comes to coding in advance, I've bit off far more than I can chew here.

I'm creating a PDF form timesheet using Acrobat Pro DC.

I managed to get the date fields to auto populate based on pay period start date, now I would like to put a condition that hides or prevents the fields near the bottom of the timesheet from populating with dates from the next pay period. Pay periods run from 1st to 15th and 16th-end of month.

For custom validation script for the pay period start date dropdown list (Date1) I have:

if (event.value != "") {
    var date1 = util.scand("dd/mm/yy", event.value);
    if (date1 != null) {
        var date2 = new Date(date1);
        date2.setDate(date1.getDate() + 0);
        this.getField("Date2").value = util.printd("dd/mm/yy", date2);
        date2.setDate(date1.getDate() + 1);
        this.getField("Date3").value = util.printd("dd/mm/yy", date2);
        date2.setDate(date1.getDate() + 2);
        this.getField("Date4").value = util.printd("dd/mm/yy", date2);
        date2.setDate(date1.getDate() + 3);
        this.getField("Date5").value = util.printd("dd/mm/yy", date2);
        date2.setDate(date1.getDate() + 4);
        this.getField("Date6").value = util.printd("dd/mm/yy", date2);
        date2.setDate(date1.getDate() + 5);
        this.getField("Date7").value = util.printd("dd/mm/yy", date2);
        date2.setDate(date1.getDate() + 6);
        this.getField("Date8").value = util.printd("dd/mm/yy", date2);
        date2.setDate(date1.getDate() + 7);
        this.getField("Date9").value = util.printd("dd/mm/yy", date2);
        date2.setDate(date1.getDate() + 8);
        this.getField("Date10").value = util.printd("dd/mm/yy", date2);
        date2.setDate(date1.getDate() + 9);
        this.getField("Date11").value = util.printd("dd/mm/yy", date2);
        date2.setDate(date1.getDate() + 10);
        this.getField("Date12").value = util.printd("dd/mm/yy", date2);
        date2.setDate(date1.getDate() + 11);
        this.getField("Date13").value = util.printd("dd/mm/yy", date2);
        date2.setDate(date1.getDate() + 12);
        this.getField("Date14").value = util.printd("dd/mm/yy", date2);
        date2.setDate(date1.getDate() + 13);
        this.getField("Date15").value = util.printd("dd/mm/yy", date2);
        date2.setDate(date1.getDate() + 14);
        this.getField("Date16").value = util.printd("dd/mm/yy", date2);
        date2.setDate(date1.getDate() + 15);
        this.getField("Date17").value = util.printd("dd/mm/yy", date2);
    }
}

Which corresponds to these fields:

Timesheet Dates.jpg

And displays this:

Timesheet Dates 2.jpg

So for example for February I don't want the last 3 rows to have any date at all and would prefer if they weren't fillable fields at all anymore.

Any and all help is greatly appreciated, thank you in advance! 

TOPICS
PDF forms

Views

17

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
no replies

Have something to add?

Join the conversation