Bootstrap3 DateTimePicker: minDate选项设置输入值字段
Bootstrap3 DateTimePicker: minDate option set the input value field
我在设置 minDate
选项设置输入值字段时遇到问题。为什么??
(当我写这个post时,输入的日期在minDate
之后)
Html:
<div class="row">
<div class="col-md-12">
<h6>datetimepicker</h6>
<input type="text" class="form-control" id="datetimepicker" value="21/12/2016"/>
</div>
</div>
Javascript:
$('#datetimepicker').datetimepicker({
locale: 'fr',
//minDate: moment(), If I uncomment it the input value field changes to current date
format: 'DD/MM/YYYY'
});
您必须添加 useCurrent
选项并将其设置为 false
。
这是一个工作示例:
$('#datetimepicker').datetimepicker({
locale: 'fr',
minDate: moment(),
useCurrent: false,
format: 'DD/MM/YYYY'
});
<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.17.1/moment-with-locales.min.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="row">
<div class="col-md-12">
<h6>datetimepicker</h6>
<input type="text" class="form-control" id="datetimepicker" value="21/12/2016"/>
</div>
</div>
我在设置 minDate
选项设置输入值字段时遇到问题。为什么??
(当我写这个post时,输入的日期在minDate
之后)
Html:
<div class="row">
<div class="col-md-12">
<h6>datetimepicker</h6>
<input type="text" class="form-control" id="datetimepicker" value="21/12/2016"/>
</div>
</div>
Javascript:
$('#datetimepicker').datetimepicker({
locale: 'fr',
//minDate: moment(), If I uncomment it the input value field changes to current date
format: 'DD/MM/YYYY'
});
您必须添加 useCurrent
选项并将其设置为 false
。
这是一个工作示例:
$('#datetimepicker').datetimepicker({
locale: 'fr',
minDate: moment(),
useCurrent: false,
format: 'DD/MM/YYYY'
});
<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.17.1/moment-with-locales.min.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="row">
<div class="col-md-12">
<h6>datetimepicker</h6>
<input type="text" class="form-control" id="datetimepicker" value="21/12/2016"/>
</div>
</div>