需要禁用引导程序时间选择器的输入

need to disable input for bootstrap timepicker

本文关键字:选择器 输入 时间 引导程序      更新时间:2023-09-26

我正在使用Bootstrap时间选择器。我已经成功地实现了它。但我需要的是用户只能在30分钟的时间间隔内插入,比如:10:00,10:30,11:00等。我尝试过的是minuteStep,如下所示,它非常完美。

 $('#fantasyleague-draft_time').timepicker({
     template: false,
     showInputs: false,
     minuteStep: 30
 });

但问题是用户可以根据需要键入时间。那么,如何防止它手动输入时间呢?

为此,我参考了引导程序时间选择器

在文本框中尝试这样的操作:->

<input type="text" id="fantasyleague-draft_time" readonly="readonly">

到目前为止我所做的是:

<input type="text" id="fantasyleague-draft_time" readonly>

添加CSS

fantasyleague-draft_time{cursor: pointer;}

和JS:

 $('#fantasyleague-draft_time').timepicker({
     template: false,
     showInputs: false,
     minuteStep: 30
 });

尝试<input type="text" disabled>。。它不允许做任何事情。。30分钟后使用javascript或jquery 删除disabled属性