输入获得焦点并更新日历时如何显示日期选择器日历

问题描述 投票:1回答:2

我有一个基于此URL的日历示例:http://eonasdan.github.io/bootstrap-datetimepicker

这是HTML代码:

<div class="form-group col-xs-2 col-md-2">
    <label for="datebirth" class="control-label">Date of Birth</label>
    <div class="input-group date" id="datetimepicker1">
        <input type="text" class="form-control" id="date-birth" maxlength="10" />
        <span class="input-group-addon">
            <span class="glyphicon glyphicon-calendar"></span>
        </span>
    </div>                      
</div>

这是JS代码:

moment.locale('en', {
  week: { dow: 1 } // Monday is the first day of the week
});     

$("#datetimepicker1").datetimepicker({
    format: 'DD/MM/YYYY'
});

$("#date-birth").on("focus", function() {
    //open calendar
});

我的日历必须在点击日历图标(确定)时打开,当输入日期成为焦点时,然后,如果我在输入日期字段中写了fecha,则日历窗口必须自动更新。

在URL中,有一个有关无图标(仅输入字段)的示例:,但我没有解决它。

感谢您的帮助。

twitter-bootstrap twitter-bootstrap-3 bootstrap-datetimepicker
2个回答
4
投票
您可以通过添加allowInputToggle选项来初始化日历,以便在输入获得焦点时也将其打开:

0
投票
我认为您需要更改datetimepicker的CSS。只需添加如下一行
© www.soinside.com 2019 - 2024. All rights reserved.