本文介绍了Bootstrap Datepicker禁用特定日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用引导程序禁用特定日期

I want disable specific dates with bootstrap

<script>
  $(document).ready(function(){
    var date_input=$('input[name="date"]');
    var container=$('.bootstrap-iso form').length>0 ? $('.bootstrap-iso form').parent() : "body";
    date_input.datepicker({
      format: 'yyyy-mm-dd',
      container: container,
      minDate:new Date(),
      disabledDates: ["2018-06-08","2018-06-10"],
      autoclose: true,
    })
  })
</script>

有人可以帮助我吗?非常感谢

Anybody can help me? Thanks very much

推荐答案

您已传递了无效的密钥.它的 datesDisabled 不是 disabledDates .

You have passed the invalid key. Its datesDisabled not disabledDates.

$(document).ready(function(){
    var date_input=$('input[name="date"]');
    var container=$('.bootstrap-iso form').length>0 ? $('.bootstrap-iso form').parent() : "body";
    date_input.datepicker({
      format: 'yyyy-mm-dd',
      container: container,
      minDate:new Date(),
      datesDisabled: ['2018-06-08','2018-06-10'],
      autoclose: true,
    })
  })
@import url('https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.css');
@import url('https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/css/bootstrap-datepicker3.css');
.datepicker table tr td.disabled,
.datepicker table tr td.disabled:hover {
  color: #b90000;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.2/js/bootstrap.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.5.0/js/bootstrap-datepicker.js"></script>
<input name="date">

这篇关于Bootstrap Datepicker禁用特定日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 02:14