I have this jQuery datepicker code that initially set the minDate of the datepicker. After a user selects a starting date, I used the option attribute to change the minDate of the datepicker, but nothing happens. What did I do wrong and how should I make it work?
Datepicker init code:
$(function () {
$('#starttime,#endtime,#validity').datepicker({
numberOfMonths: [1, 2],
buttonImageOnly: true,
showAnim: 'slideDown',
buttonImage: '../images/cal.gif',
beforeShow: customRange,
dateFormat: "dd-mm-yy",
firstDay: 1,
changeFirstDay: false
});
});
Datepicker change minimum date code:
var startdate = new Date(2010,4-1,
4-1,0,0,0);
$("#endtime").datepicker('option','minDate',startdate);
Actually this should work. Did you check if there are any errors in your browsers error console. And when/how do you call the
$("#endtime").datepicker('option','minDate',startdate);code?Btw. is April, 3rd 2010 really the date you mean?
Check this for a working demo: http://jsbin.com/ecome (http://jsbin.com/ecome/edit for the code)