Hello i'm trying to disable all saturdays from my calendar
the calendar is contact form 7 and its using jquery-ui-datepicker
this is my short code :
[date* your-date date-479 id:datepiicker min:today placeholder "date de reservation*" ]
and this is my Jquery code :
jQuery(document).ready(function($) {
$("#datepiicker").datepicker({
beforeShowDay: function(date) {
var day = date.getDay();
return [(day != 6), ''];
}
});
});
but its not working
$("#datepiicker").datepicker({
beforeShowDay: function(date) {
var day = date.getDay();
return [(day != 6), ''];
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" />
<input type="date" id="datepiicker" />
the solution in my case is to check the day. If it's saturday i can reset the value and tell the user to pick something else using alert.
jQuery(document).ready(function($) {
const picker = document.getElementById('datepiicker');
picker.addEventListener('input', function(e){
var day = new Date(this.value).getUTCDay();
if([6].includes(day)){
e.preventDefault();
this.value = '';
alert("This day is not available ");
}
});
});