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>