Sandeep sandy Sandeep sandy - 2 months ago 7
jQuery Question

How to disable and enable datetimepicker jquery plugin

I have a requirement like enabling and disabling datetimepicker plugin from input box.

<select id="sel">
<option value="opt1" data-type="date">opt1</option>
<option value="opt2" data-type="string">opt2</option>
</input><input id="inp">

<script>
$('#sel').on('change', function(){
var type = $('this').find('option:selected').data(type);
if(type == 'date'){
//enable calendar
$('#inp').datetimepicker();
} else {
//need to disable
}
});
</script>


Want to enable if type is date if not need to disable calendar. Any help appreciable.

Answer

If you'll find time and read datetimepicker manual you will see a couple of methods even with examples:

hide - Hide Datetimepicker

toggle - Show/Hide Datetimepicker

destroy - Destroy datetimepicker

Now, choose which one you want.

Comments