Datejs Help: Move Date in "Textbox1" to Next Month End in "Textbox2"
Hi,
I have two text boxes in a PDF form: "Month Ended" and "Due Date." The user is supposed to enter a month end date in the "Month Ended" text box. This is validated to be a "mm/dd/yyyy" format.
When the user enters a date in "Month Ended" I want to auto-calculate the "Due Date" field. It should always be the last day of the next month and account for leap years. For example, if I put in 08/31/2016 (Month Ended text box) it should return 09/30/2016 (Due Date text box). Or if I put in 01/31/2016 it should return 02/29/2016 (since we have a leap year this year). Please note I also tried to account for the scenario where a user might not follow directions and enter a "month end" date (i.e. would instead enter the middle of the month, etc.).
I thought Datejs would work but I can't seem to get it to work. Here is the script I have in "Custom Calculation script" field of the "Due Date" text box:
var MonthEnded = thisgetField("Month Ended").value;
MonthEnded.moveToLastDayOfMonth();
MonthEnded.addMonths(1);
MonthEnded.moveToLastDayofMonth();
event.value = util.printd("mm/dd/yyyy",MonthEnded");
Can anyone help me accomplish what I'm trying to do?
Thanks,
A
