2017-03-23 71 views
0

我使用的是Bootstrap 3 Datetimepicker,我需要禁用所有未來的日期,我知道它有它自己的disabledDates函數,但我嘗試了很多次,但仍然無法正常工作。在Bootstrap中禁用將來的日期3 Datetimepicker

我在做什麼錯?

$('#data_move').datetimepicker({ 
    language: 'pt-BR', 
    disabledDates: [ 
     moment("22/02/2017") 
    ] 
}); 
+0

http://eonasdan.github.io/bootstrap-datetimepicker/Functions/#minmaxdate –

回答

4

,您應該使用maxDate選項,而不是disabledDates

這裏工作的例子:

$('#data_move').datetimepicker({ 
 
    locale: 'pt-br', 
 
    maxDate: moment() 
 
});
<link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet"/> 
 
<link href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/css/bootstrap-datetimepicker.css" rel="stylesheet"/> 
 

 
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js"></script> 
 
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/locale/pt-br.js"></script> 
 
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.js"></script> 
 
<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js"></script> 
 

 
<div class='input-group date' id='data_move'> 
 
    <input type='text' class="form-control" /> 
 
    <span class="input-group-addon"> 
 
    <span class="glyphicon glyphicon-calendar"></span> 
 
    </span> 
 
</div>

+0

它沒有工作:( – MattDAVM

+0

請問snippet for you?你確定你使用的是eonasdan datetimepicker? – VincenzoC

+0

是的,它的工作原理,我使用的是我提到的datetimepicker確定 – MattDAVM

相關問題