Looking for assistance with a JavaScript problem. I have created functions that generate dates based on user input of a start date, but now I need to ensure that only working days (excluding weekends and holidays) are populated. How can I modify my code to accommodate this?
Current code snippet:
function GetModifiedDate(date, noOfDaysAdded) {
var inputstring = date;
var dString = inputstring.split('/');
var dt = new Date(dString[2], dString[0] - 1, dString[1]);
dt.setDate(dt.getDate() + parseInt(noOfDaysAdded));
var finaldate = (String(dt.getMonth() + 1)) + '/' + (String(dt.getDate())) + '/' + (String(dt.getFullYear()));
return finaldate;
}
function AutoPopulateDatesForLndMgmtCust(obj) {
var val = obj.value;
var table = $('#tblLndMgmtCust');
var rowLength = table[0].rows.length;
var modifieddate = val;
incrementDay = [2, 1, 3, 1, 5, 2, 10, 4, 10, 2, 2, 2, 1, 1];
for (var i = 0; i < rowLength - 2; i += 1) {
var row = table[0].rows[i + 2];
var cell = row.cells[2];
modifieddate = GetModifiedDate(modifieddate, incrementDay[i] * 1);
cell.children[0].children[0].value = modifieddate;
}
}
Thank you in advance!