title: jQuery UI Datepicker - Disable specific days selected from database not from arrays
body: <p>Thanks in advance for your cooperation,</p>
  
  <p>I'm using this JQUERY Date picker as shown in this image :
  <a href="http://techblog.willshouse.com/wp-content/uploads/2009/06/datepicker.jpg" rel="nofollow noreferrer">http://techblog.willshouse.com/wp-content/uploads/2009/06/datepicker.jpg</a></p>
  
  <p>and for more information :
  I have an ASP.net site retrieving data from SQL server 2008..
  one of the admin functionalities is to change official holidays dates and save them in the DB in table Holidays</p>
  
  <p>my question is:
  how to disable these official holidays in the datepicker , so i prevent the user to select these specific days.</p>
  
  <p>following this link:</p>
  
  <p><a href="https://stackoverflow.com/questions/677976/jquery-ui-datepicker-disable-specific-days">jQuery UI Datepicker - Disable specific days</a></p>
  
  <p>but I’m afraid I can’t use this solution manner , because the official holidays  can’t be listed in an array since they are changed periodically many times by the admin of the site.</p>
  
  <p>So, I don’t need to add them to the array list every time the admin change them.</p>
  
  <p>I mean, is there any way to disable the selected  dates from the table "Holidays" in the database?</p>
  
  <p>Thanks in advance,</p>
  
  <p>--- and also , i try to use this answer...  </p>
  
  <pre><code>    /* create an array of days which need to be disabled */
  
      var disabledDays = ["2-21-2010","2-24-2010","2-27-2010","2-28-2010","3-3-2010","3-17-2010","4-2-2010","4-3-2010","4-4-2010","4-5-2010"];
  
      /* utility functions */
      function nationalDays(date) {
              var m = date.getMonth(), d = date.getDate(), y = date.getFullYear();
              //console.log('Checking (raw): ' + m + '-' + d + '-' + y);
              for (i = 0; i &lt; disabledDays.length; i++) {
                              if($.inArray((m+1) + '-' + d + '-' + y,disabledDays) != -1 || new Date() &gt; date) {
                                              //console.log('bad:  ' + (m+1) + '-' + d + '-' + y + ' / ' + disabledDays[i]);
                                              return [false];
                              }
              }
              //console.log('good:  ' + (m+1) + '-' + d + '-' + y);
              return [true];
      }
      function noWeekendsOrHolidays(date) {
              var noWeekend = jQuery.datepicker.noWeekends(date);
              return noWeekend[0] ? nationalDays(date) : noWeekend;
       }
  
      /* create datepicker */
      jQuery(document).ready(function() {
              jQuery('#date').datepicker({
                              minDate: new Date(2010, 0, 1),
                              maxDate: new Date(2010, 5, 31),
                              dateFormat: 'DD, MM, d, yy',
                              constrainInput: true,
                              beforeShowDay: noWeekendsOrHolidays
              });
  </code></pre>