/ / Como desativar a data específica do Jquery UI datepicker - javascript, jquery, html, jquery-ui, datepicker

Como desativar a data específica do JQuery UI datepicker - javascript, jquery, html, jquery-ui, datepicker

Quero desativar as datas 20,21,25 OUT 2015. Estou usando o datepicker da interface do usuário do JQuery, mas não consigo obter saída. Aqui está o meu código de exemplo.

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Datepicker functionality</title>
<link href="http://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>

<!-- Javascript -->
<script>
var unavailableDates = ["10/20/2015", "10/21/2015", "10/25/2015"];

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({
dateFormat: "dd MM yy",
beforeShowDay: unavailable
});

});
</script>
</head>
<body>
<!-- HTML -->
<p>Enter Date: <input type="text" id="datepicker-5"></p>
</body>
</html>

Respostas:

1 para resposta № 1

você pode tentar isso

d = $("#myDatepicker1").datepicker("getDate");
$("#myDatepicker2").datepicker("setDate", new Date(d.getFullYear()+1,d.getMonth(),d.getDate()));