从jquery datepicker禁用除过去2天之外的所有过去日期

时间:2022-11-30 09:31:34

I am trying to disable all past dates from the date-picker except for the last 2 dates. How can i do that?

我试图禁用日期选择器中的所有过去日期,除了最后2个日期。我怎样才能做到这一点?

<link href="Content/jquery-ui-1.8.23.custom.css" rel="stylesheet" />
<script src="Scripts/jquery-1.8.1.min.js"></script>
<script src="Scripts/jquery-ui-1.9.2.custom.min.js"></script>

    <script type="text/javascript">
        $(document).ready(function () {
            $('.datepicker').datepicker();
        });
</script>

here is my textbox

这是我的文本框

  <asp:TextBox ID="txtDate" runat="server" CssClass="datepicker" >asp:TextBox>  

2 个解决方案

#1


1  

you can use minDate option for this:

你可以使用minDate选项:

$( "#datepicker" ).datepicker({ minDate: -2});

#2


1  

Use this

$("#datepicker").datepicker({
        minDate: -2
});

Working Fiddle

#1


1  

you can use minDate option for this:

你可以使用minDate选项:

$( "#datepicker" ).datepicker({ minDate: -2});

#2


1  

Use this

$("#datepicker").datepicker({
        minDate: -2
});

Working Fiddle