智能表单只弹出datepicker而不是时间选择器

时间:2016-05-03 09:48:26

标签: javascript jquery datetimepicker

我正在使用Smart Form插件来设置日期和时间。一切都已设置并正常工作,但我只能在文本字段上看到日历弹出,而演示时间选择器附加到它。 我的HTML读起来像这样:

<div class="smart-wrap">
<div class="smart-forms smart-container wrap-2">

    <div class="form-header header-primary">
        <h4><i class="fa fa-clock-o"></i> Date Time Picker </h4>
    </div><!-- end .form-header section -->

    <form method="post" action="/" id="smart-form">
        <div class="form-body">
            <div class="spacer-b30">
                <div class="tagline"><span> Inline date-time picker </span></div><!-- .tagline -->
            </div>

            <div class="section cal-widget">
                <div class="spacer-b10">
                    <input type="text" name="dtpfield" id="dtpfield" class="gui-input" />
                </div>
                <span id="dtpicker" ></span>
            </div><!-- end section --> 


            <div class="form-footer">
                <button type="submit" class="button btn-primary"> Submit Form </button>
                <button type="reset" class="button"> Cancel </button>
            </div><!-- end .form-footer section -->
        </div>
    </form>
</div><!-- end .smart-wrap section -->

我的js读起来像这样

$(function() {
    $('#dtpicker').datetimepicker({
         altField: "#dtpfield",
         altFieldTimeOnly: false,                   
         prevText: '<i class="fa fa-chevron-left"></i>',
         nextText: '<i class="fa fa-chevron-right"></i>'
    });
});

1 个答案:

答案 0 :(得分:0)

您应该尝试在代码中添加 timeFormat ,例如

$(function() {
    $('#dtpicker').datetimepicker({
         controlType: 'select',
    oneLine: true,
    timeFormat: 'hh:mm tt',                 
         prevText: '<i class="fa fa-chevron-left"></i>',
         nextText: '<i class="fa fa-chevron-right"></i>'
    });
});