minDate在bootstrap datepicker中不起作用

pyn*_*ice 7 datepicker twitter-bootstrap

我正在使用这个bootstrap datepicker http://www.eyecon.ro/bootstrap-datepicker/:

<script type="text/javascript">
var dateToday = new Date();
$(function() {
    $("#id_deadline").datepicker({minDate: dateToday});
});
</script>
Run Code Online (Sandbox Code Playgroud)

我想让我们选择从今天到未来的日期(不是过去的日期).Datepicker正在显示,它也让我选择过去的日期.怎么了?

tet*_*tri 21

尝试使用这种方式:

$("#id_deadline").datepicker({ startDate: "today" });
Run Code Online (Sandbox Code Playgroud)

使用startDate参数不需要Date var.


Moh*_*med 6

尝试使用startDate这种方式:

$("#id_deadline").datepicker({startDate: new Date()});
Run Code Online (Sandbox Code Playgroud)

我希望它会对你有所帮助


Bik*_*net 6

因为没有一个答案对我有用.我设法通过使用onRender选项禁用旧日期

$('.datepicker').datepicker({
          onRender: function(date) {
            return date.valueOf() < new Date().valueOf() ? 'disabled' : '';
        }
    }); 
Run Code Online (Sandbox Code Playgroud)