Try setting the maxDate option to 0, this set the max date to +0 days from today.
$(".datepicker").datepicker({maxDate: '0'});
More info: http://api.jqueryui.com/datepicker/#option-maxDate
Вопрос
Is there any other way by which I cannot allow the user to select next months. I had gone through some threads but I don't want to disable both next and previous buttons by using step functionality as directed in this link.
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"
});
}
Решение 2
Try setting the maxDate option to 0, this set the max date to +0 days from today.
$(".datepicker").datepicker({maxDate: '0'});
More info: http://api.jqueryui.com/datepicker/#option-maxDate
Другие советы
Well if you are looking to simply remove the next/previous options and only use a forced month in your code, you can use CSS.
.ui-datepicker-next,.ui-datepicker-prev{display:none;}
This will just remove the next/prev buttons all together. Then if need be you can even put in like some .toggle() code to show/hide them when needed.
If you only want to hide the next/previous when they're disabled (ie. all valid dates are within a single month), use the following:
.ui-datepicker-prev.ui-state-disabled { display: none; }
.ui-datepicker-next.ui-state-disabled { display: none; }
Datepicker with hiding next and prev buttons and date format and defined date.
$("#dateTextId")
.datepicker({dateFormat: "dd-M-y",stepMonths:0})
.datepicker('setDate',new Date(date_string));