开发者

Jquery datepicker: disable federal holidays

开发者 https://www.devze.com 2022-12-28 02:05 出处:网络
i am working on asp.net using C# and using jquery datepicker my question is, how can i disable dates which are federal holidays?

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

my question is, how can i disable dates which are federal holidays?

i have a dynamic dates which comes from开发者_如何学Go sql server.

anybody have done something similar or any idea how can i 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(); }  
    });  
}); 

Thanks.


         // 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


You might want to look at a different plugin, this one supports bank holidays, so starting from that example, you can probably do what you want to do:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消