2 回答
TA贡献1835条经验 获得超7个赞
您可以使用datepicker 的 beforeShowDay来禁用日期。即:
//disable these dates
var datesForDisable = ["25.01.2019", "26.01.2019", "27.01.2019"]
$("#txt_dateDebut").datepicker({
format: 'dd/mm/yyyy',
autoclose: true,
weekStart: 1,
calendarWeeks: true,
todayHighlight: true,
beforeShowDay: function(date){
//format date in datepicker to dd-mm-yy
var date1 = $.datepicker.formatDate('dd.mm.yy', date);
//disable dates
return [ datesForDisable.indexOf(date1) == -1 ]
}
});
<link href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/base/jquery-ui.css" rel="stylesheet" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"></script>
<input type="text" class="form-control" id="txt_dateDebut" value="<?php echo $uneLocation->getDateDebut(); ?>" name="txt_dateDebut" required>
TA贡献1712条经验 获得超3个赞
如果您使用引导日期选择器使用,
$('.#txt_dateDebut').datepicker({
beforeShowDay:function(Date){
var curr_date = Date.getDate();
var curr_month = Date.getMonth()+1;
var curr_year = Date.getFullYear();
var curr_date=curr_month+'/'+curr_date+'/'+curr_year;
if (datesForDisable.indexOf(curr_date)>-1) return false;
}
});
- 2 回答
- 0 关注
- 147 浏览
添加回答
举报