javascript - how to disable unavilable dates dynamically in datepicker -


i'm trying disable unaviable dates dynamically how can ?

if give static value below working fine

var unavailabledates = ["10-8-2015","24-7-2015","10-7-2015","09-8-2015","09-7-2015","01-12-2015","01-1-2016","11-8-2015"];   

if value dynamically not working how can solve ?

my fiddle

var unavailabledates = $('#designidunavialble').html();  function unavailable(date) {     dmy = date.getdate() + "-" + (date.getmonth() + 1) + "-" + date.getfullyear();     if ($.inarray(dmy, unavailabledates) == -1) {         return [true, ""];     } else {         return [false, "", "unavailable"];     } }  $(function() {     $("#idate").datepicker({         defaultdate: new date("7-7-2015"),         mindate:0,         dateformat: 'dd-mm-yy',         beforeshowday: unavailable     });  }); 

whats wrong in code.anybody me ?

try working demo

just change date format m/d/y

$(document).ready(function(){ var desingndate = $('#designidunavialble').html(); var splitdate = desingndate.split(',');    // console.log(splitdate.length);     var arrdisableddates = {};     (var = 0; < splitdate.length; i++) {         //console.log(splitdate[i]);         arrdisableddates[new date(splitdate[i])] = new date(splitdate[i]);         }       $("#idate").datepicker({                dateformat: 'dd-mm-yy',         beforeshowday: function (dt) {             var bdisable = arrdisableddates[dt];             if (bdisable) return [false, '', ''];             else return [true, '', ''];         }     });  }); 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -