How to not show a mobile keyboard when using bootstrap-datepicker?

GusP picture GusP · Apr 12, 2015 · Viewed 16.2k times · Source

I tried setting the disableTouchKeyboard option but it did nothing -- at least on iOS/Safari. The options I was specifically using were:

$(".datepicker").datepicker({
    autoclose: true,
    disableTouchKeyboard: true,
    format: 'm/d/yyyy',
    startDate: '01/01/1900',
    todayBtn: 'linked',
    todayHighlight: true,
});

Anyone know what the best way to do this is?

Answer

Philip Enc picture Philip Enc · Oct 28, 2015

If you are using Bootstrap3 Datepicker:
https://eonasdan.github.io/bootstrap-datetimepicker

Just add this property to the input: readonly="readonly" and this property
to options when instantiate the library.

$('#datetimepicker1').datetimepicker({
        useCurrent: false,
        daysOfWeekDisabled: [0, 6],
        format: 'DD-MM-YYYY',
        ignoreReadonly: true   <------ this property
});

Tested on Safari iPhone and Chrome / Native browser Android.