gpt4 book ai didi

javascript - 如何使用 Bootstrap DateTimePicker 链接 DateTime?

转载 作者:行者123 更新时间:2023-11-30 14:49:33 25 4
gpt4 key购买 nike

我有一张包含出发日期和返回日期的表格。我想在返回日期字段中设置最小日期是所选出发日期的日期。我已经将 id 放在 div 标签或 input 标签中,但没有任何效果。你知道为什么吗?

<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Departure<span class="required"> *</span></label>
<div class="input-group date form_datetime col-md-4 col-sm-4 col-xs-12" id="res_departure1" data-link-field="dtp_input1">
<input class="form-control pull-right" size="16" type="text" value="" readonly required>
<input type="hidden" id="dtp_input1" name="res_departure" value="" />
<span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Return<span class="required"> *</span></label>
<div class="input-group date form_datetime col-md-4 col-sm-4 col-xs-12" id="res_return1" data-link-field="dtp_input2">
<input class="form-control pull-right" size="16" type="text" value="" readonly required>
<input type="hidden" id="dtp_input2" name="res_return" value="" />
<span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
</div>
</div>

这是我的js

$('.form_datetime').datetimepicker({
//language: 'fr',
format: "yyyy-mm-dd hh:ii",
autoclose: true,
todayBtn: true,
startDate: new Date
});

$("#res_departure1").on("dp.change", function (e) {
$('#res_return1').data("DateTimePicker").setMinDate(e.date);
});

最佳答案

$('#res_departure1').datetimepicker().on('changeDate', function(ev) {
var departureDate = ev.date;
$('#res_return1').datetimepicker('setStartDate', departureDate);
});

$('#res_return1').datetimepicker().on('changeDate', function(ev) {
var returnDate = ev.date;
$('#res_departure1').datetimepicker('setEndDate', returnDate);
});

关于javascript - 如何使用 Bootstrap DateTimePicker 链接 DateTime?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48376362/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com