Insights
Jquery Date time picker – Show only required dates enabled
<html>
<head>
<script src=”https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js”></script>
<script type=”text/javascript” src=”https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.20/jquery.datetimepicker.full.min.js”></script>
<link rel=”stylesheet” type=”text/css” href=”https://cdnjs.cloudflare.com/ajax/libs/jquery-datetimepicker/2.5.20/jquery.datetimepicker.css”>
</head>
<body>
<script>
jQuery(document).ready(function(){
var allowedDate = [“02-06-2024″,”03-06-2024″,”04-06-2024”];
jQuery(‘#date-needed’).datetimepicker({
format: ‘Y-m-d’,
timepicker:false,
// maxDate: ”,
onShow:function( ct ){
this.setOptions({
// minDate: ‘-11d’,
})
},
minDate: new Date(2024,6-1,2), // this will show only the date starting fro 2 June 2024
maxDate: new Date(2024,6-1,19), // this will show only date till 19 June 2024
defaultDate: new Date(2024,6-1,6), // this will force thedefault selected date
beforeShowDay: function(date) { // This will show only those day that are declared under allowedDate array
var currentDate = (“0” + date.getDate()).slice(-2) + “-” + (“0” + (date.getMonth()+1)).slice(-2) + “-” + date.getFullYear();
return jQuery.inArray(currentDate, allowedDate) === -1 ?[false, “notav”, “Not Available”]:[true, “av”, “Available”];
}
});
});
</script>
<input type=”text” id=”date-needed”>
</body>
</html>
You can check the live example here
Turn insight into action
Need help with html or a related project?
If this article sparked an idea, question, or project direction, I can help you turn it into a practical next step.
Most recent
Latest posts from the blog
Why a headless CMS fits a personal brand website
A personal website can feel warm and editorial while still being structured, fast and easy to manage behind the scenes.
Read articleWhat matters in a WordPress blog migration
The migration is not only about moving posts. URLs, assets, authors, metadata and redirects all protect long-term search value.
Read articleMicrosoft Makes OpenAI’s $200/Month AI Free for All Copilot Users
Microsoft has recently made significant advancements in AI accessibility by integrating OpenAI’s advanced o1 model into its Copilot feature, now available for free to Windows users. Previously, unlimited access to this model required a subscription costing up to $200 per month. The o1 model, released in December 2024,
Read article




