Disabling weekends on Elementor Form/Calendar
Hi, I already have some codes for my calendar here and they work very well:
add_action('wp_footer', function () {
if ( ! is_page( 1035 ) ) {
return;
}
?>
<script>
jQuery( document ).ready( function( $ ){
function waitForFlatpicker( callback ) {
if ( typeof window.flatpickr !== 'function' ) {
setTimeout( function() { waitForFlatpicker( callback ) }, 25 );
}
callback();
}
waitForFlatpicker( function(){
flatpickr.l10ns.pt = {
weekdays: {
shorthand: ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"],
longhand: [
"Sonntag",
"Montag",
"Dienstag",
"Mittwoch",
"Donnerstag",
"Freitag",
"Samstag",
],
},
months: {
shorthand: [
"Jan",
"Feb",
"März",
"Apr",
"Mai",
"Jun",
"Jul",
"Aug",
"Sept",
"Okt",
"Nov",
"Dez",
],
longhand: [
"Januar",
"Februar",
"März",
"April",
"Mai",
"Juni",
"Juli",
"August",
"September",
"Oktober",
"November",
"Dezember",
],
},
firstDayOfWeek: 1,
weekAbbreviation: "KW",
rangeSeparator: " bis ",
scrollTitle: "Zum Ändern scrollen",
toggleTitle: "Zum Umschalten klicken",
time_24hr: true,
};
//set translations
flatpickr.localize(flatpickr.l10ns.pt);
flatpickr('.flatpickr-input');
//set format
$('.flatpickr-input').each(function(){ flatpickr( $(this)[0] ).set('dateFormat', 'dd/mm/yyyy');});
});
});
</script>
<?php
} );
**and also I found some code for disabling Weekends from https://flatpickr.js.org/examples/#disabling-dates this: **
{
"disable": [
function(date) {
// return true to disable
return (date.getDay() === 0 || date.getDay() === 6);
}
],
"locale": {
"firstDayOfWeek": 1 // start week on Monday
}
}
Just I don't know how to integrate this code to mine from flatpickr. Could you help me please?
@bulutemre
This is not really an Elementor Question but more of a flatPicker, anyway, It looks like you just need to set the disable option after you set the Format ex:
$('.flatpickr-input').each( function(){
flatpickr( $(this)[0] ).set('dateFormat', 'dd/mm/yyyy');
flatpickr( $(this)[0] ).set('disable', function( date) { return (date.getDay() === 0 || date.getDay() === 6); });
});
Thanks
It didn't work :( I wrote also Flatpickr Github and they said I should ask on Stackoverflow, I also wrote there but nobody answered :( Could you help a little bit more?
It didn't work :( I wrote also Flatpickr Github and they said I should ask on Stackoverflow, I also wrote there but nobody answered :( Could you help a little bit more?
Hello @bulutemre I am a beginner at WordPress. I want to disable only Sundays on elementor form. Could you tell me in detail, how can I upload the code on my elementor? Thanks in advance