datepicker on button click not working
-
I have a datepicker which needs to have its date disabled only on button click. below is the code on button click. I actually wanted to use returned data but for now to check I am only using availableDates for blocking. Please help.
posting.done(function (data) {
var date = new Date();
var temp = data.split(",");
alert(data);
var year = (new Date).getFullYear();
$("#datepicker").datepicker();
var availableDates = ['01-25-2021'];
$("#datepicker").datepicker({
beforeShowDay: function (d) {
var dmy = (d.getMonth() + 1);
if (d.getMonth() < 9)
dmy = "0" + dmy;
dmy += "-";
if (d.getDate() < 10) dmy += "0";
dmy += d.getDate() + "-" + d.getFullYear();
if ($.inArray(dmy, availableDates) != -1) {
return [false];
} else {
return [true];
}
}
});
})Dhyanga