i want to use datepicekr as check-in - check-out so I have HTML:
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="datum">Datum: Od</label>
<div class="col-md-3">
<input id="dp1" name="dp1" class="form-control" placeholder="Datum" type="text">
</div>
<div class="col-md-3">
<input id="dp2" name="dp2" class="form-control" placeholder="Datum" type="text">
</div>
</div>
I try to make it workable with js:
var nowTemp = new Date();
var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);
var checkin = $("#dp1").datepicker({
onRender: function(date) {
return date.valueOf() < now.valueOf() ? 'disabled' : '';
}
}).on('changeDate', function(ev) {
if (ev.date.valueOf() > checkout.date.valueOf()) {
var newDate = new Date(ev.date)
newDate.setDate(newDate.getDate() + 1);
checkout.setValue(newDate);
}
checkin.hide();
$("#dp2")[0].focus();
}).data('datepicker');
var checkout = $("#dp2").datepicker({
onRender: function(date) {
return date.valueOf() <= checkin.date.valueOf() ? 'disabled' : '';
}
}).on('changeDate', function(ev) {
checkout.hide();
}).data('datepicker');
but I get error:
Uncaught TypeError: Cannot read property 'valueOf' of undefined
What that exactly mean? What I can do to solve this problem? I use the code from official web resource for datepicker for bootstrap...