JQuery how to increase date

I have two input fields: one with a start date and one with an end date. How can I automatically set the end date as the start date + 1 day when I enter the date in the first field?
My code is as follows:

<form> Start: <input type="text" name="date_start" id="datepicker0"> Stop: <input type="text" name="date_stop" id="datepicker1"> </form> 
+4
source share
1 answer

Demo - http://jsfiddle.net/ffwr2/1/

 $('#date1').datepicker(); $('#date2').datepicker(); $('#date1').change(function(){ var date1 = $('#date1').datepicker('getDate'); var date = new Date( Date.parse( date1 ) ); date.setDate( date.getDate() + 1 ); var newDate = date.toDateString(); newDate = new Date( Date.parse( newDate ) ); $('#date2').datepicker('setDate', newDate ); }) 
+10
source

All Articles