title: To disable dynamic dates and days in jquery datepicker
body: <p>I have used jquery ui datepicker and i want to disable some specific date range coming from database and also days.so i have written below code but it's not working</p>
  
  <pre><code>function checkAvailability(mydate){
  var $return=true;
  var $returnclass ="available";
  $checkdate = $.datepicker.formatDate('dd-mm-yy', mydate);
      var datas  =$.parseJSON(disabledDays);
              var unavailableDates=[];
              for(i in datas){
                  unavailableDates.push(datas[i]); 
              }
  
   for(var i = 0; i &lt; unavailableDates.length; i++) 
      {    
         if(unavailableDates[i] == $checkdate)
         {
              $return = false;
              $returnclass= "unavailable";
         }
      } 
   var day = mydate.getDay();         
   //return [(day!=0) &amp;&amp; $return,$returnclass];
  
          var disabledDaysRange  =$.parseJSON(disabledDays_Range);
          var unavailableDays=[];
          for(j in disabledDaysRange){
                  unavailableDays.push(disabledDaysRange[j]); 
           }
           var days_return = '';
          for(var j = 0; j &lt; unavailableDays.length; j++) 
           {    
                  if(unavailableDays[j] == day)
                      {
                          days_return =days_return.concat( day +'!= '+unavailableDays[j]+ ' &amp;&amp; '); 
                      }
            } 
                if(days_return!=''){
                      days_return = "( " + days_return + ")"; 
                      days_return = days_return.replace("&amp;&amp; ) ", " )");
                 }
             if(days_return!=''){         
              return [days_return &amp;&amp; ($return),$returnclass];
             }else{
                 return [$return,$returnclass];
             }
  }     
  </code></pre>