bootstrap-datetimepicker 开始时间与结束时间互相约束

JS

    $("#start").datetimepicker({
        keyboardNavigation: false,
        language: 'zh-CN',
        forceParse: false,
        autoclose: true,
        format: 'yyyy-mm-dd hh:ii',
        startDate: new Date()
    }).on("click", function () {
        $("#start").datetimepicker("setEndDate", $("#end").val())
    });


    $("#end").datetimepicker({
        keyboardNavigation: false,
        language: 'zh-CN',
        forceParse: false,
        autoclose: true,
        format: 'yyyy-mm-dd hh:ii',
        startDate: new Date()
    }).on("click", function () {
        $("#end").datetimepicker("setStartDate", $("#start").val())
    });

HTML

    <div class="input-group">
        <input type="text" id="start"/>
        <span class="input-group-addon"></span>
        <input type="text" id="end"/>
    </div>

 

posted @ 2017-11-20 14:12  Red丶  阅读(2173)  评论(3编辑  收藏  举报