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

Question

Question

How to disable weekends for calendar field

asked on June 15, 2017 Show version history

Is there a script to exclude weekends from calendar field

0 0

Answer

SELECTED ANSWER
replied on June 15, 2017

Here is a demo for Forms 10.2 and above, it will restrict date picker and check if manual input is valid:

 (set date field with CSS class 'myDate')

$(document).ready(function(){
  function isCorrectDate(n) {
    var t = n.getDay();
    return (t!=6 && t!=0);
  }
  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('noweekend', {
    validateString: function(value) {
      return isCorrectDate(new Date(value));
    },
    messages: {
      en: 'Not valid date.'
    }
  });
  $('.myDate input').attr('data-parsley-noweekend','');
})

Similiar with https://answers.laserfiche.com/questions/121274/Restrict-date-to-second-Saturday-of-each-month

1 0
replied on June 16, 2017

That worked. Thank you so much Rui.

0 0

Replies

replied on June 15, 2017

What product are we talking about here? Forms? Desktop Client? Web Access?

0 0
replied on June 15, 2017

Forms

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

Sign in to reply to this post.