This is a date range picker. This is already working and validating startDate and endDate input values. My question is how can I put a value to the endDate field?
Ex. if startDate is selected at 2020-2-27, the endDate field will be filled up with the value 2020-2-28.
<input type="text" class="form-control" placeholder="yyyy-mm-dd" id="startDate"> <input type="text" class="form-control" placeholder="yyyy-mm-dd" id="endDate"> This is my code. I am using the bootstrap datepicker
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js"></script> <script> var start = new Date(); var end = new Date(new Date().setYear(start.getFullYear()+1)); $('#startDate').datepicker({ endDate : end }).on('changeDate', function(){ $('#endDate').datepicker('setStartDate', new Date($(this).val())); }); $('#endDate').datepicker({ startDate : start, endDate : end }).on('changeDate', function(){ $('#startDate').datepicker('setEndDate', new Date($(this).val())); }); </script>