gpt4 book ai didi

jQuery timepicker 插件限制 end_time 字段

转载 作者:行者123 更新时间:2023-12-01 02:22:21 24 4
gpt4 key购买 nike

我正在 2 个带有 #start_time 和 #end_time id 的文件上使用 jQuery 时间选择器插件 ( https://github.com/trentrichardson/jQuery-Timepicker-Addon )。我希望#end_time必须更大或者从#start_time的时间开始。我尝试了下面的代码,但我不擅长 jQuery。

$(function() {
$('#start_time').timepicker({
onClose: function(timeText, inst) {
if ($('#end_time').val() != '') {
var testStartTime = $('#start_time').timepicker('getTime');
var testEndTime = $('#end_time').timepicker('getTime');
if (testStartTime > testEndTime)
$('#end_time').timepicker('setTime', testStartTime);
}
else {
$('#end_time').val(timeText);
}
},
onSelect: function (selectedTime){
$('#end_time').timepicker('option', 'minTime', $('#start_time').timepicker('getTime') );
}
});
$('#end_time').timepicker({
onClose: function(timeText, inst) {
if ($('#start_time').val() != '') {
var testStartTime = $('#start_time').timepicker('getTime');
var testEndTime = $('#end_time').timepicker('getTime');
if (testStartTime > testEndTime)
$('#start_time').timepicker('setTime', testEndTime);
}
else {
$('#start_time').val(timeText);
}
},
onSelect: function (selectedTime){
$('#start_time').timepicker('option', 'maxTime', $('#end_time').timepicker('getTime') );
}
});
});

我有两个时间输入 start_time 和 end_time。

最佳答案

        var startDateTextBox = $('#dialog_missionAdd input[name=scheduleStarttime]');
var endDateTextBox = $('#dialog_missionAdd input[name=scheduleEndtime]');

startDateTextBox.timepicker({
defaultValue: "00:00",
timeFormat: "HH:mm",
onClose: function(dateText, inst) {
if (endDateTextBox.val() != '') {
var testStartTime = startDateTextBox.datetimepicker('getDate');
var testEndTime = endDateTextBox.datetimepicker('getDate');
if (testStartTime > testEndTime) {
endDateTextBox.timepicker('setDate', testStartTime); }
}
else {
endDateTextBox.val(dateText);
}
},
onSelect: function (selectedDateTime) {
endDateTextBox.datetimepicker('option', 'minDate', startDateTextBox.datetimepicker('getDate') );
}
});

endDateTextBox.timepicker({
defaultValue: "00:00",
timeFormat: "HH:mm",
onClose: function(dateText, inst) {
if (startDateTextBox.val() != '') {
var testStartTime = startDateTextBox.datetimepicker('getDate');
var testEndTime = endDateTextBox.datetimepicker('getDate');
if (testStartTime > testEndTime) {
startDateTextBox.timepicker('setDate', testEndTime); }
}
else {
startDateTextBox.val(dateText);
}
},
onSelect: function (selectedDateTime) {
startDateTextBox.datetimepicker('option', 'maxDate', endDateTextBox.datetimepicker('getDate') );
}
});

关于jQuery timepicker 插件限制 end_time 字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12869592/

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