How to disable Bootstrap datetimepicker

user7933742 picture user7933742 · May 18, 2017 · Viewed 13.5k times · Source

I am using the Bootstrap datatimepicker (https://eonasdan.github.io/bootstrap-datetimepicker/). I'd like to disable the datetimepicker on page load.

$(document).ready(function () {
    $('#datetimepicker1').datetimepicker({
        defaultDate: new Date(),
        format: 'DD/MM/YYYY hh:mm:ss A'
    });
});

<div class='input-group date' id='datetimepicker1'>
    <input type='text' class="form-control" />
    <span class="input-group-addon">
        <span class="glyphicon glyphicon-calendar"></span>
    </span>
</div>

I have tried $('#datetimepicker1').prop('disabled', true) and $('#datetimepicker1').disable() from (http://eonasdan.github.io/bootstrap-datetimepicker/Functions/#disable). Neither work. So what is the best way to do it?

Answer

komal picture komal · May 18, 2017

try the following code $('#datetimepicker1 > .form-control').prop('disabled', true); please check the link https://jsfiddle.net/komal10041992/DTcHh/32829/