Jquery datepicker: disable federal holidays

I am working on asp.net using C # and using jquery datepicker

My question is: how can I turn off dates that are federal holidays?

I have dynamic dates that come from a SQL server.

Has anyone done something like this or any idea how I can achieve this?

$(document).ready(function () {       
  $('#endDate').datepicker({ showOn: 'button',  
      buttonImage: '../images/Calendar.png',  
      buttonImageOnly: true, onSelect: function () { },  
      onClose: function () { $(this).focus(); }  
    });  

  $('#startDate').datepicker({ showOn: 'button',  
      buttonImage: '../images/Calendar.png',  
      buttonImageOnly: true, onSelect:  
        function (dateText, inst) {  
          $('#endDate').datepicker("option", 'minDate', new Date(dateText));  
        }  
      ,  
      onClose: function () { $(this).focus(); }  
    });  
}); 

Thank.

+3
source share
2 answers
         // April 30,2010 and May 1, 2010 are disabled
var disabledDates = ['04/30/2010', '05/01/2010'];

$(function(){

    $('#datepicker').datepicker({

        dateFormat: 'dd/mm/yy',
        beforeShowDay: editDays
    });

    function editDays(date) {
        for (var i = 0; i < disabledDates.length; i++) {
            if (new Date(disabledDates[i]).toString() == date.toString()) {             
                 return [false];
            }
        }
        return [true];
     }   

});

demo

+5
source

You might want to look at another plugin that supports bank holidays, so starting with this example, you can probably do what you want:

http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/

+1
source

Source: https://habr.com/ru/post/1742387/


All Articles