gpt4 book ai didi

javascript - DateTimePicker 类预约系统

转载 作者:行者123 更新时间:2023-11-29 11:00:42 26 4
gpt4 key购买 nike

我需要为日期和时间准备一个输入,它可以在特定日期禁用时间。我为此准备了一个 Bootstrap 3 DateTimePicker:

$('#ScheduledAt').datetimepicker({
format: 'YYYY-MM-DD HH:mm',
disabledDates: [
moment("2017-12-05 9:00"),
],
daysOfWeekDisabled: [0, 7],
stepping: 30,
enabledHours: [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18],
})

步进是 30 分钟,所以在 2017-12-05 9:00 有人预订了东西,但在 2017-12-05 9:30 我可以创建预订。当我像上面那样设置时,我不能点击这个特定的日期并选择另一个时间。有没有可能这样做?还是其他插件?

最佳答案

你试过 disabledtimeintervals 了吗? eonasdan bootstrap-datetimepicker 的选项?

这是一个 CodePen:https://codepen.io/beaver71/pen/gXyrwR显示此功能。

$('#ScheduledAt').datetimepicker({
format: 'YYYY-MM-DD HH:mm',
toolbarPlacement: 'top',
showClear: true,
showClose: true,
sideBySide: true,
disabledTimeIntervals: [
[moment("2017-12-05 8:40"),moment("2017-12-05 9:20")],
],
daysOfWeekDisabled: [0, 7],
stepping: 30,
enabledHours: [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18],
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js?ver=1"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.19.0/moment-with-locales.js"></script>
<script src="https://cdn.rawgit.com/Eonasdan/bootstrap-datetimepicker/5a991bff/src/js/bootstrap-datetimepicker.js"></script>
<link href="https://cdn.rawgit.com/Eonasdan/bootstrap-datetimepicker/master/build/css/bootstrap-datetimepicker.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<div class="col-md-4">
<div class="panel-body">
<form id="srcForm">
<div class="row">
<div class="form-group col-xs-12">
<label>Date</label>
<div id="ScheduledAt" class="input-group">
<input type="text" class="form-control" name="from">
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
</form>
</div>
</div>
</div>

区间[moment("2017-12-05 8:40"),moment("2017-12-05 9:20")]用于禁用2017- 12-05 9:00 日期时间。

关于javascript - DateTimePicker 类预约系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47642835/

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