문제

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');

 });
도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top