need to disable input for bootstrap timepicker

亡梦爱人 提交于 2019-12-22 05:26:09

问题


I am using Bootstrap time-picker. I have successfully implemented it. But what I need is user is only able to insert in 30 min gap like: 10:00,10:30,11:00 etc. For that I have tried is minuteStep as shown below, and it works perfect.

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

But what is the issue is user can type time as he need. So, how to prevent it to enter time manually?

For this I have refer bootstrap timepicker


回答1:


Try something like this in your text box :->

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



回答2:


What i have done so far now is :

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

Added CSS

fantasyleague-draft_time{cursor: pointer;}

and JS:

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



回答3:


Try <input type="text" disabled>..it will not allow to do anything..after 30 min remove disabled attribute using javascript or jquery



来源:https://stackoverflow.com/questions/34555563/need-to-disable-input-for-bootstrap-timepicker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!