1

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

 });

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.