You are viewing limited content. For full access, please sign in.

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

In Forms, how can the calendar picker be set to disable or gray out weekends and holidays? And not on Cloud?

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 5, 2024

It looks like this code is not for the Modern Forms Designer.

1 0
replied on July 5, 2024

Correct, this is for Classic Form Designer. There might be a way around it, but "Window" is disabled in Modern Forms. 

0 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
replied on July 3, 2024

Thank you for your help, and wish I had Cloud lol.

0 0
replied on July 3, 2024

Bummer! Hopefully the feature will be rolled out for on prem users soon.

1 0
replied on July 3, 2024

This feature will come out for the new form designer in LF12!

3 0
replied on July 3, 2024

Woohoo!!! Thanks, you guys!

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.