I have a datepicker with ID "dtpicker".
I need to make sure that user will get an alert popup if selected date is within five working days from current day(today).
I have a almost working solution:
function DateRule()
{
var dt = new Date();
dt.setDate(dt.getDate() + 5);
var date = dt.toISOString().substring(0, 10);
userdatepick = NWF$("#" + datepicker).val();
if (userdatepick < date)
{
alert("Reminder: you have selected a startdate that is earlier then five workingdays from todays date")
}
}
I tested this with todays date and it works almost as it suppose to when I select dates throught datepicker between 2010-10-18 - 2010-10-22 I get the alert reminder which is correct. When I select 2010-10-23 I dont get reminder alert, but it should since its weekend day and not working day. 2010-10-25 should not give reminder thought.
Could a solution be to ignore weekend days when adding five days to current date(today). For an example when I add five days to my variable It jumps over weekend days?
Any help or tips is appreciated