我想将用户可以选择的日期限制为从今天的日期起2年,默认情况下,用户可以选择无限日期
下面是我尝试过的代码
使用的库:
ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js maxcdn.bootstrapcdn.com/bootstrap/3.3.6 css/bootstrap.min.css /datepicker.css maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js js/bootstrap-datepicker.js
<input type="text" id="datepicker1">
<script>
$('#datepicker1').datepicker({
endDate:'+2y'
});
</script>
上面的代码没有限制日期
救命啊!
我也尝试了下面的代码,但在这种情况下,数据报警器是内联数据转发器,我不需要内联数据转发器。
<head>
http://192.168.0.27:8080/hostbook/public_html/js/jquery.js
http://192.168.0.27:8080/hostbook/public_html/assests/css/bootstrap-datepicker3.css
http://192.168.0.27:8080/hostbook/public_html/assests/js/bootstrap-datepicker.js
</head>
<input name="check_in" id="check_in" type="text" class="datepicker search-date" autocomplete="off" />
<script>
$(document).ready(function(){
$('#check_in').datepicker({ format: "dd/mm/yyyy",
startView: "months",
endDate:'+2y',
})
});
</script>
发布于 2015-12-28 20:47:06
您还没有为startDate
指定datePicker
来决定endDate
。只需将其添加到选项中如下:
$('#datepicker1').datepicker({
startDate:new Date(), //Today's Date
endDate:'+2y'
});
https://stackoverflow.com/questions/34504517
复制