Jquery Disabled Dates next working days

by Akram kamal

HTML

<p>Date:
    <input type="text" id="datepicker">
</p>

JavaScript

var goodDates = []

 function DisableBad(date) {
     if (goodDates.length === 0) { // initialize
         var now = new Date();
         while (goodDates.length < 3) { // 3 is the number of good days, 
             var day = now.getDate() + 1
             now.setDate(day)
             if (now.getDay() < 5)
                 goodDates.push($.datepicker.formatDate( "yy-mm-dd",now))
         }
     }
     return [$.inArray($.datepicker.formatDate( "yy-mm-dd",date), goodDates)>-1];
 }

 $(function() {
     $("#datepicker").datepicker({
         beforeShowDay: DisableBad,
         beforeShow: function(el, e) {
             goodDates = [];
         }
     });
 });