Reputation: 15715
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');
});
Upvotes: 1
Views: 1022
Reputation: 1542
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);
}
Upvotes: 3