我有以下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'
},
});
当我最初加载页面时,输入字段将填充今天的日期。我该如何防止这种情况发生?
答案 0 :(得分: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
});
};