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

Question

Question

DatePicker with blocked holidays doesn't work

asked on March 18, 2021

Hi,

i am trying to insert a datepicker calendar with holidays and weekends blocked, when i run my code outside of Laserfiche it works normaly, but when i try to run it in Forms with javascript code i only have the displayed calendar and holidays are not blocked. what's wrong ? i have too this error in my calendar when i choose date 

Value must be between 1900-01-01 and 2200-12-31.

this is my code 

 



 $(document).ready(function () {
  var holidays = [
    '1.1.2021',
    '2.1.2020',
    '20.2.2020',
    '19.1.2020',
    '1.8.2020',
    '15.8.2020',
    '1.11.2020',
    '8.12.2020',
    '25.12.2020',
    '26.12.2020'
  ];
  function noSundaysOrHolidays(date) {
    var day = date.getDay();
    if (day != 0) {
      var d = date.getDate();
      var m = date.getMonth();
      var y = date.getFullYear();
      for (i = 0; i < holidays.length; i++) {
        if($.inArray((d) + '.' + (m+1) + '.' + y, holidays) != -1) {
          return [false];
        }
      }
      return [true];
    } else {
      return [day != 0, ''];
    }
  }

  $('#Field6').datepicker({
    onClose: function(dateText, inst) { 
        $(this).attr("disabled", false);
    },
    beforeShow: function(input, inst) {
      $(this).attr("disabled", true);
    },
    beforeShowDay: noSundaysOrHolidays,
    minDate: 0,
    dateFormat: 'dd.mm.yy',
  });
});
		

 

0 0

Replies

replied on March 18, 2021

There is a full walkthrough on this post regarding setting something like this up:

https://answers.laserfiche.com/questions/170752/Ability-to-restrict-dates-in-forms#182435

After doing that walkthough on that post, I've used the same code to implement this type of functionality on 3 different forms processes.

0 0
replied on November 7, 2024

Hi, we have supported configuring holiday calendars on Forms 12.

You can see other changes from: Laserfiche 12 Changelog

Get Laserfiche Forms 12 package from: Laserfiche 12 - Downloads

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

Sign in to reply to this post.