【发布时间】:2021-09-13 20:19:51
【问题描述】:
我通过在项目中导入this JS file 来使用Eonasdan datetimepicker version : 4.17.47。
另外,我正在使用一些自定义验证来确保当用户输入与预期不同的时间范围时显示红色文本。我没有设置minDate或maxDate,因为时间范围是动态的,可以更改。
但有时,用户无法通过单击向上箭头键来增加小时/分钟。 datetimepicker 设置为仅使用时间,因此初始化为:
$("#timePicker").datetimepicker({
format: "LT",
allowInputToggle: true,
keepInvalid: true // the up arrow icon was not working, so I thought this will fix it but it didn't
});
和模板:
<div class="form-group col-sm-6 time-block">
<div class="control input-group customtextInput" id="timePicker">
<input type="text" id="stime" name="time" class="inputText col-md-12 form-control time-picker"
data-bind="event:{ blur: function (data, event) {$parent.handleDateTimeOnblur.bind(data, $parent, event)() } }"
required />
<span class="input-group-addon">
...
</span>
</div>
<p class="text-danger login-error-msg time-empty" id="time-error" aria-label="Error Message"
data-bind="text: $parent.timeErrorMessage()" role="alert"></p>
</div>
你可以看一个演示here
我注意到,当用户尝试使用 datetimepicker 转到下一个日期时,它会停止递增,(此给定页面上的日期选择器未连接,它们是单独初始化的。)
对此的任何帮助将不胜感激!
【问题讨论】:
-
这个问题stackoverflow.com/questions/64611566/…或许对你有帮助。
-
嘿何塞,感谢您的回复,您是否认为时间没有使用箭头图标更新,因为
dp.change没有被解雇?虽然当我尝试通过单击小时和分钟的数值来更新时间时;然后它可以工作,但不能使用箭头图标
标签: javascript jquery knockout.js bootstrap-datetimepicker eonasdan-datetimepicker