0

I have a datepicker field that the maxDate doesn't seem to be working on.

jQuery:

$(document).ready(function() {
    $("#intorgDate").change(function() {
        var myDate = new Date($("#intorgDate").val()); //ENTER VALUE IN mm/dd/yy FORMAT
        var mymaxDate = new Date(myDate +7);
        $('#intnewDate').datepicker({
            inline: true,
            dateFormat: "mm/dd/yy",
            changeFirstDay: false,                  
            defaultDate:myDate,
            minDate: myDate,
            maxDate: mymaxDate
        });
    });
});​

HTML:

org date:<br>
<input type="text" id="intorgDate" /><br>
new date:<br>
<input type="text" id="intnewDate" /><br>​

I have also tried setting maxDate to: maxDate: myDate 7, maxDate: myDate +7, and myDate "+7" - All with no luck.

You can see it in action here: http://jsfiddle.net/eQRqt/30/

What am I missing?

Edited by dschuett

1
Contributor
1
Reply
4
Views
5 Years
Discussion Span
Last Post by dschuett
0

Finally got this working with:

//Destroy Previous Datepicker
$('#intnewDate').datepicker("destroy");
//Create New Datepicker
var orgDate = $.datepicker.parseDate('mm/dd/yy', $('#intoriginalDate').val());
orgDate.setDate(orgDate.getDate());
var maxDate = $.datepicker.parseDate('mm/dd/yy', $('#intoriginalDate').val());
var maxDays = parseInt(23);
maxDate.setDate(maxDate.getDate() + maxDays);
$('#intnewDate').datepicker({
    inline: true,
    beforeShowDay: noWeekendsOrHolidays,
    dateFormat: "mm/dd/yy",                  
    defaultDate:orgDate,
    minDate: orgDate,
    maxDate: maxDate
});

Hopefully someone can find this usefull.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.