views:

187

answers:

2

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);
A: 

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)

jitter
I tried a few times with this. Doesn't seem to work.
futureelite7
Check expanded answer. I made a demo where your exact code (minus the `buttonImage` and the `beforeShow` options) works exactly like expected. So your problem must lie somewhere else. Again I ask where/when/how do you call the `$("#endtime").datepicker('option','minDate',startdate);` code? As you still didn't answer that or provide more code
jitter
A: 

Maybe try the following:

$("#endtime").datepicker('option', {minDate:startdate});
Tim