【问题标题】:Datepicker for Bootstrap on mobile devices changing Format移动设备上 Bootstrap 的 Datepicker 更改格式
【发布时间】:2014-11-27 08:11:50
【问题描述】:

我正在使用以下日期选择器:(http://eternicode.github.io/bootstrap-datepicker/) 作为我的日期字段。

<input class="datepicker" style="width:100px;border-radius: 4px;" type="text" placeholder="Datum" id="startDate"....

我正在使用两种不同的格式“dd.mm.yyyy”和“mm/dd/yyyy”,一切都很好。 但在移动设备上,当我点击输入字段时,键盘会打开。

因此,我使用带有 <input type='date'.... 的原生日期选择器,但这个不支持不同的格式。

有没有办法在input type=text 元素上禁用键盘?

或者你知道其他不同格式的日期选择器吗?

感谢您的帮助

【问题讨论】:

  • 找到解决办法:刚刚在输入中添加了属性readonly='true'

标签: twitter-bootstrap mobile datepicker format input-field


【解决方案1】:

试试这个:如果你添加 onfocus="blur();"到元素这不会让软键盘打开。因此,您不会在移动设备上打开键盘。

$('#sandbox-container input').datepicker({});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://unpkg.com/bootstrap-datepicker@1.9.0/dist/js/bootstrap-datepicker.min.js"></script>
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://unpkg.com/bootstrap-datepicker@1.9.0/dist/css/bootstrap-datepicker3.min.css" rel="stylesheet"/>


<div id="sandbox-container"><input type="text" class="form-control" onfocus="blur();"></div>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-28
    相关资源
    最近更新 更多