禁用日历中的所有日期

Disable all dates in a calendar

有什么办法可以禁用日历中的所有日期吗?目前日历构造为:

$('.date-picker-field').datepicker( {
    showOtherMonths: true,
    selectOtherMonths: true,
    changeMonth: true,
    changeYear: true,
});

这将显示启用了所有日期的日历。我想显示,禁用所有日期。

您可以使用 beforeShowDay 方法和 return 具有 false 个值的数组:

$("#datepicker").datepicker({
  beforeShowDay:function(date){
     return [false, ''];
  }
});
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>

<input type="text" id="datepicker">