Robert Ross Robert Ross - 1 year ago 107
Javascript Question

Disabling datepicker on an input field

Cuurently I have an input field using

. I am wondering how to disable the datepicker callendar popping up when I click on that field, since on my page I want the date option to be available only on certain conditions.

<input id="date" type="text " class="form-control datepicker" name="date" value="Click to select date">

I tried with :


And with :

$( "#date" ).datepicker( "disabled", true );

None worked.

Answer Source

One of the easiest way is to remove all the pointer events for that input field.

$("#date").css('pointer-events', 'none');

This will keep the data intact if you want.

And to re enable pointer events.

   $("#date").css("pointer-events", "");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download