bootstrap datepicker只能选择小于今天的日期
1、html代码
<div class="date-picker pull-left"> <div id="datepicker"></div> <div> <div class="input-group pull-left"> <span class="input-group-addon left-addon"> <img src="~/assets/img/datepicker-icon.png"> </span> <input type="text" id="dp" name="dp" placeholder="加入开始日" value="" class="date-input"> <span class="input-group-addon right-addon"><i class="fa fa-angle-down"></i></span> </div> <div class="input-group pull-left" style="margin-left: 30px;"> <span class="input-group-addon left-addon"> <img src="~/assets/img/datepicker-icon.png"> </span> <input type="text" id="end" name="end" placeholder="加入结束日" value="" class="date-input"> <span class="input-group-addon right-addon"><i class="fa fa-angle-down"></i></span> </div> </div> </div>
2、js代码
$('#dp').datepicker({ todayBtn: "linked", autoclose: true, todayHighlight: true, endDate: new Date() }); $('#end').datepicker({ todayBtn: "linked", autoclose: true, todayHighlight: true, endDate: new Date() });