Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery ui Datepicker maxDate dynamically

Good Morning, I'd like to control dynamically the maxDate of my datepicker. For examp. : I have a date on my form on a textbox with value 20/12/12.

I tried this but is not working, the calendar is disabling the maxDate from the date i got on my textbox. Can you please help me with this:

$(function() { 
    var date = new Date(); 
    var m = date.getMonth(), d = date.getDate(), y = date.getFullYear(); 
    $("#Panel2nrFecha").datepicker({ 
        minDate: new Date(y, m, d), 
        maxDate: $("#Panel2nrTextBox1").val(), 
        dateFormat: "dd/mm/y", 
        defaultDate: "+1w", 
        changeMonth: true, 
        numberOfMonths: 3 
    }); 
}); 
like image 837
tonydeleon Avatar asked Nov 12 '12 12:11

tonydeleon


1 Answers

After you have initialized your datepicker, you can change the maxDate option like this:

$("#Panel2nrFecha").datepicker('option', 'maxDate', $("#Panel2nrTextBox1").val() );
like image 152
Nelson Avatar answered Nov 12 '22 19:11

Nelson