引导日期选择器限制

Bootstrap datepicker restriction

本文关键字:选择器 日期      更新时间:2023-09-26

我在一个表单中使用Bootstrap日期拾取器。我希望它只有当前日期和当前日期之后的每个日期。这就是为什么我使用了下面的函数:

$('#datedepart').datepicker({
    onRender: function(date) {
    return date.valueOf() < now.valueOf() ? 'disabled' : '';
  }

使用这个日期选择器

        <div class="form-group col-lg-2 col-md-2">
            <label class="funzies" for="pweazed">Le:</label>
            <input type="text" data-role="date" name="date"  id ="datedepart"  class="datepicker form-control col-lg-5" value=""  required >
        </div>

当我验证我的表格与日期选择器限制,我得到了这个错误

{"success":false,"data":[],"message":"Undefined index: data","errors":null,"tid":null,"trace":null,"count":null,"totalCount":null,"metaData":[]}

事实是,我得到这个错误只有当我使用这个限制。限制本身是在日期选择器上工作,我可以选择过去的日期,但它使我的表单崩溃,只通过添加这几行…

我怎么能解决这个问题?

你应该使用startDate选项的引导日期拾取器

https://bootstrap-datepicker.readthedocs.org/en/latest/options.html startdate可以