views:

443

answers:

1

How do I set the #endDatePicker 1 month to the future of the selected date from #startDatePicker?

I am not figuring this one out but I am sure it is easier than I am making it.

Here is what I am starting out with. Now I need a function that calculates exactly 1 month(not just 30 days) into the future based on the selected date from the #startDatePicker.

    $("#startDatePicker").datepicker({
        minDate: +0,
    });

    $("#endDatePicker").datepicker({
        minDate: '+1m',
        beforeShow: customMinDate
    });

Any help appreciated.

+2  A: 

Not sure what you mean by "not just 30 days" but this should do what you want.

$("#endDatePicker").datepicker({
    minDate: '+1m',
    beforeShow: function() {
        //get date startDate is set to
        var startDate = $("#startDatePicker").datepicker('getDate');
        //if a date was selected else do nothing
        if (startDate != null) {
            startDate.setMonth(startDate.getMonth()+1);
            $(this).datepicker('option', 'minDate',startDate);
        }
    }
});
jitter
Thanks much~! That worked.
infatti
Then please consider upvoting + accepting my answer to honor my effort
jitter
You could accept now, as you have more than 15reppoints
jitter