In Forms, how can the calendar picker be set to disable or gray out weekends and holidays? And not on Cloud?
Question
Question
In Forms, how can the calendar picker be set to disable or gray out weekends and holidays? And not on Cloud?
asked on July 3, 2024
•
Show version history
0
0
Replies
replied on July 5, 2024
You can do this with Javascript now. This link shows how to disable weekends.
You can use the below modified code to also grey out your holidays. You will use "myDate" as the CSS field. You will need to add your holidays to the holidayList.
$(document).ready(function () { /*Limits date selection exclude weekends and holidays*/ //Add your holidays in string format. All holidays must be in holidayList. const holidayList = ['2024-7-5','2024-8-14']; // Checks if date is a holiday or a weekend function isCorrectDate(n) { var t = n.getDay(); var c = n.getFullYear() + "-"+(n.getMonth()+1)+ "-"+n.getDate(); var h = holidayList.includes(c) return (t!=0 && t!=6 && h==false); } //Sets up date picker with greyed out weekends and holidays. function checkDate(n) { return[isCorrectDate(n),""]; } function checkField(input, inst) { if ($(input).closest('li').hasClass('myDate')) { $(input).datepicker("option", {beforeShowDay: checkDate}); } } $.datepicker.setDefaults( {beforeShow: checkField} ); window.Parsley.addValidator('secondsat', { validateString: function(value) { return isCorrectDate(new Date(value)); }, messages: { en: 'Not valid date.' } }); $('.myDate input').attr('data-parsley-secondsat',''); });
1
0
replied on July 3, 2024
In the Modern Designer (in Cloud anyway), this is possible under the Advanced Tab, under "Only Allow Specific Dates">Allow these days of the week.
0
0
You are not allowed to follow up in this post.