jquerydatetimepickermindate

How can I set datetime picker minDate dynamically?


I'm using a datetimepicker by trentrichardson.com. I have a form with two input fields: "from" and "to" and want to be able to dynamically set a minDate to my "to" field equal to the value of my "from" field.

I know I should use a beforShow option but don't know how to implement the function.

$('.from,.to').datetimepicker({

    beforeShow: customRange

});

Solution

  • you can set and get minDate dynamically with setter and getter:

    //getter
    var minDate = $( ".selector" ).datepicker( "option", "minDate" );
    //setter
    $( ".selector" ).datepicker( "option", "minDate", new Date(2007, 1 - 1, 1) );
    

    explained here