3

How to disable alphabet entering in Bootstrap time Picker.

My time Picker code is:

<div class="bootstrap-timepicker">
  <input
    id="timepicker4"
    type="text"
    class="form-control"
    name="startingTime"
    value="00:00"
    required
  />
</div>

And Jquery Calling function is:

jQuery('#timepicker4').timepicker({showMeridian: false}). 

What can I do? But i dont need to disable Input i only need dont type alphabets..

Bala Murugan
  • 479
  • 5
  • 10

2 Answers2

2

Set the showInput false, then display time in span tag

showInputs : false
msvairam
  • 862
  • 5
  • 12
1

You can do this many way.

First way to do: JSFiddle
Second way to do: JSfiddle

You can use onkeyup="this.value=this.value.replace(/[^\d]/,'')" in your input field.

jQuery('#timepicker4').timepicker({
  showMeridian: false
})
<div class="bootstrap-timepicker">
  <input id="timepicker4" type="text" class="form-control" name="startingTime" value="00:00" onkeyup="this.value=this.value.replace(/[^\d]/,'')" required/>
</div>
Chonchol Mahmud
  • 2,717
  • 7
  • 39
  • 72