0

我有以下 HTML:

<input type="text" id="received-date" name="received-date" required="required" class="date-picker form-control col-md-7 col-xs-12">

$('.date-picker').daterangepicker({
          singleDatePicker: true,
          locale: {
            format: 'DD/MM/YYYY'
          },
        });

当我最初加载页面时,输入字段填充了今天的日期。我该如何防止这种情况发生?

4

1 回答 1

0

添加 autoUpdateInput: false 如下所示

$(document).ready(function() {
  $('.date-picker').singleDatePicker();
});

$.fn.singleDatePicker = function() {
  $(this).on("apply.daterangepicker", function(e, picker) {
    picker.element.val(picker.startDate.format(picker.locale.format));
  });
  return $(this).daterangepicker({
   singleDatePicker: true,
   autoUpdateInput: false
  });
};
于 2017-01-25T11:35:19.150 回答