I have application which has time gets bind dynamically where scenario may allowed time can be null,
In Jquery datetimepicker setting allowed time null set as example shown here which supposed to be null
How to set null time?
$(document).ready(function(){
try{ $('.DATETIMEFIELD').datetimepicker({
value:'',
datepicker:false,
format:'h:i A',
formatTime: 'h:i A',
step:30 ,
allowTimes: [],
});
}
catch(e){
console.log(e);
};
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.20/jquery.datetimepicker.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.20/jquery.datetimepicker.full.js" id="_carbonads_js" defer></script>
<input type="text" class="DATETIMEFIELD">
You can destroy date time picker in case if array is null. Here is both situation where you can check before you bing datetimepicker.
$(document).ready(function(){
var timedata1=[32, 33, 12, 40]
var timedata2=[]
try{
$('.DATETIMEFIELD').datetimepicker({
value:'',
datepicker:false,
format:'h:i A',
formatTime: 'h:i A',
step:30 ,
allowTimes:timedata1,
});
if(timedata2.length==0 || timedata2==null){
$(".DATETIMEFIELD1").datepicker("destroy");
}else{
$('.DATETIMEFIELD1').datetimepicker({
value:'',
datepicker:false,
format:'h:i A',
formatTime: 'h:i A',
step:30 ,
allowTimes:timedata1,
});
}
}
catch(e){
console.log(e);
};
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.20/jquery.datetimepicker.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.20/jquery.datetimepicker.full.js" id="_carbonads_js" defer></script>
While Having Value
<input type="text" class="DATETIMEFIELD">
While not Having Value
<input type="text" class="DATETIMEFIELD1">