最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - need to disable input for bootstrap timepicker - Stack Overflow

programmeradmin6浏览0评论

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

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

Share Improve this question edited Jan 6, 2016 at 12:48 Ishan Shah asked Jan 1, 2016 at 11:01 Ishan ShahIshan Shah 1,6762 gold badges20 silver badges43 bronze badges 1
  • after fiddling a while with the Bootstrap time-picker i came to the conclusion that you might have to do a hack with the Bootstrap time-picker js code to get it working the way you intended. Anyway Good Luck :-) – jyrkim Commented Jan 3, 2016 at 7:52
Add a ment  | 

3 Answers 3

Reset to default 2

Try something like this in your text box :->

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

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
 });

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

发布评论

评论列表(0)

  1. 暂无评论