问题描述
我在使用引导程序datetimepicker
时遇到了严重问题,这是 jsfiddle :
I have a serious problem with bootstrap datetimepicker
, Here is the jsfiddle :
<br/>
<!-- padding for jsfiddle -->
<div class="row">
<div class="col-md-12">
<h6>datetimepicker1</h6>
<div class="form-group">
<div class="input-group date" id="datetimepicker1">
<input type="text" class="form-control" > <span class="input-group-addon"><span class="glyphicon-calendar glyphicon"></span></span>
</div>
</div>
</div>
</div>
问题是,当我在移动设备上打开网站时,当我关注输入字段时会触发移动键盘,所以我需要的是仅显示datepicker
而没有键盘.因此,为此,我使用readonly
或disabled
,但是问题是当我使用其中之一时,引导程序datetimepicker
不起作用. http://jsfiddle.net/faissal_aboullait/kx0e5wmq/1/
The problem is that when i open my website in mobile, mobile keyboard triggered when i focus the input field so what i need is that only the datepicker
show without keyboard. So for that i use readonly
or disabled
, but the problem is that when i use one of them the bootstrap datetimepicker
doesn't work.http://jsfiddle.net/faissal_aboullait/kx0e5wmq/1/
推荐答案
如果您仍在寻找解决方案,请查看代码段.这正是我在评论中建议的,您只需使用
If your are still looking for a solution take a look at the snippet. This is exactly what i suggested in the comment, you just have to call datetimepicker with
ignoreReadonly: true
就是这样.
$(function () {
$('#datetimepicker').datetimepicker({
ignoreReadonly: true
});
});
.container {
margin-top: 80px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.7.14/css/bootstrap-datetimepicker.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.3/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.7.14/js/bootstrap-datetimepicker.min.js"></script>
<div class="container">
<div class="row">
<div class="col-sm-12">
<div class='col-sm-6 col-sm-offset-3'>
<div class="form-group">
<div class='input-group date' id='datetimepicker'>
<input type='text' class="form-control" readonly />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
使用图标选择日期而不是文本字段.文本字段是只读的.
Use the icon to pick your date not the text field. The text field is read only.
这篇关于Bootstrap DateTimePicker不适用于只读或已禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!