在Jquery datepicker中禁用Next

有没有其他方法可以让我不允许用户选择下个月。 我已经完成了一些线程,但我不想通过使用此链接中指示的步骤function来禁用下一个和上一个按钮。

function bindPicker() { $("input[type=text][id*=Date]").datepicker({ changeMonth: true, changeYear: true, yearRange: "-100:+0", showOn: "both", buttonImage: "../../images/Calender.png", buttonImageOnly: true, dateFormat: "M-yy" }); } 

尝试将maxDate选项设置为0,这会将最大日期设置为从今天开始的+0天。

 $(".datepicker").datepicker({maxDate: '0'}); 

更多信息: http : //api.jqueryui.com/datepicker/#option-maxDate

好吧,如果您只想删除下一个/上一个选项并且只在代码中使用强制月,则可以使用CSS。

 .ui-datepicker-next,.ui-datepicker-prev{display:none;} 

这将只删除下一个/上一个按钮。 然后,如果需要,您甚至可以像某些.toggle()代码一样在需要时显示/隐藏它们。

如果您只想在禁用它们时隐藏下一个/上一个(即所有有效日期都在一个月内),请使用以下命令:

 .ui-datepicker-prev.ui-state-disabled { display: none; } .ui-datepicker-next.ui-state-disabled { display: none; } 

Datepicker隐藏了next和prev按钮以及日期格式和定义的日期。

 $("#dateTextId") .datepicker({dateFormat: "dd-My",stepMonths:0}) .datepicker('setDate',new Date(date_string));