Disable Keyboard When using jQuery UI Datepicker in Textbox

Updated on     Kisan Patel


How to disable keyboard including Backspace when using jQuery UI datepicker in input textbox?ution


Here, we need to use both javascript keypress and keydown events because when using keypress event you cannot handle Backspace keyboard button. You must use javascript keydown event to disable Backspace button.

$("#txtdate").keypress(function (e) {
      return false;
$("#txtdate").keydown(function (e) {
         return false;

Here is the complete example including the jQuery UI datepicker with diable keyboard input using javascript keypress and keydown event.

See the Pen pjRjbO by Kisan (@pka246) on CodePen.


Leave a Reply