0

Hi I am working on rails4 project and I want to disable all national holidays and weekend dates in my pickadate. Or I have to use pickdate.js I am not getting how to do this. I have done the following for disabling the weekends.

 $( '.new_leave_datepicker' ).pickadate({
        selectMonths: true,
        selectYears: 25,
        disable: [
            1,7
        ],
        min: Date.now()
    });

Its working fine for this but how to do for national holidays that am not getting. I am having table holidays in which I have holidaydates. Please guide what steps I have to follow for this. Thanks in advance.

Dinshaw Raje
  • 933
  • 1
  • 12
  • 33

3 Answers3

0

You can disable sets of dates by the following methods:

   picker.set('disable', [

      // Using a collection of arrays formatted as [YEAR,MONTH,DATE]
      [2016,9,3], [2016,9,9], [2016,9,20],

      // Using JavaScript Date objects
      new Date(2015,9,13), new Date(2015,9,24)
    ])

Please refer this link http://amsul.ca/pickadate.js/api/#method-set-disable-enable

Akshay Borade
  • 2,442
  • 12
  • 26
0

You can pass an array of disabled dates like this:

var datesToDisable = [ 1, 4, 7, [2015,3,8], [2015,3,19], new Date(2015,3,26) ]


$( '.new_leave_datepicker' ).pickadate({
    selectMonths: true,
    selectYears: 25,
    disable: datesToDisable,
    min: Date.now()
});
usmanali
  • 2,028
  • 2
  • 27
  • 38
-1

You can use jquery-ui datepicker. There is a method named noWeekends.

$( "#datepicker" ).datepicker({
   beforeShowDay: $.datepicker.noWeekends
});

But there is no documentation for National holidays. You have to customize the datepicker options.

Emu
  • 5,763
  • 3
  • 31
  • 51
  • may I ask why it's got the down vote? It might help me to find my mistakes. – Emu Jun 04 '15 at 05:49
  • I am not the one who down voted your answer. While I can tell "WHY?", READ the question carefully and then see your answer. You'll know WHY. – Surya Jun 04 '15 at 06:16