I want to create an entry date for a project. here I use the datepicker from bootstrap.
here my code :
<input class="form-control tanggal" id="date" autocomplete="off" name="date_start" placeholder="YYYY-MM-DD" type="text" readonly="" required="">
<input class="form-control tanggal" autocomplete="off" id="date_end" name="date_end" placeholder="YYYY-MM-DD" type="text" readonly="" required="required">
and this my javascript :
<script>
$(document).ready(function(){
var date_input=$('input[name="date_start"]'); //our date input has the name "date"
var container=$('.bootstrap-iso form').length>0 ? $('.bootstrap-iso form').parent() : "body";
var currentdate = new Date();
currentdate.setDate(currentdate.getDate() + 1);
var tomorrow = currentdate.toJSON().slice(0,10);
date_input.datepicker({
format: 'yyyy-mm-dd',
container: container,
todayHighlight: true,
autoclose: true,
startDate: tomorrow
})
})
$(document).ready(function(){
var date_input=$('input[name="date_end"]'); //our date input has the name "date"
var container=$('.bootstrap-iso form').length>0 ? $('.bootstrap-iso form').parent() : "body";
var currentdate = new Date();
currentdate.setDate(currentdate.getDate() + 1);
var tomorrow = currentdate.toJSON().slice(0,10);
date_input.datepicker({
format: 'yyyy-mm-dd',
container: container,
todayHighlight: true,
autoclose: true,
startDate: tomorrow
})
})
</script>
my problem is how i can set my date_end is start from +1 day
after date_start and cant select the day less than date_start ? have some one give me solution?
what code should I add? to make it work like what i want ?
@Adam Projo
I have checked your fiddle and implemented the below code and it works. Please provide id="start_date"
for date_start and id="end_date"
for date_end . Please have a look
$(document).ready(function(){
$("#start_date").datepicker({
todayBtn: 1,
autoclose: true,
}).on('changeDate', function (selected) {
var minDate = new Date(selected.date.valueOf());
minDate.setDate(minDate.getDate()+1);
$('#end_date').datepicker('setStartDate', minDate);
});
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.