Question

I have two text-boxes in which user have to select dates. I want to trigger second date-picker when the first date is selected. Please help.

Here is the fiddle.

and this is the code :

 $('input[data-date="date"]' ).datepicker();
     $($('input[data-date="date"]' ).get(0)).change(function(e){
        console.log("triggered");
        $($('input[data-date="date"]' ).get(1)).trigger('focus');

 });
Was it helpful?

Solution

On your onSelect event in Jquery ui datepicker ,

onSelect: function( selectedDate ) {
    $( "#to" ).datepicker("option", "minDate", selectedDate );
    setTimeout(function(){
        $( "#to" ).datepicker('show');  //where 'to' is your second date
    },30);
}

FIDDLE DEMO

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top