我正在使用bootstrap-datepicker我需要将其配置为仅允许选择当月的当天到结束日,我不想允许用户浏览月份,这可能吗?如何?我阅读了文档,但没有发现任何真正有帮助的内容
最佳答案
1) 您可以使用 bootstrap datepicker 的 startDate
和 endDate
选项。
2)在startDate中设置今天的日期
var today = new Date();
3)要获取该月的最后日期,请使用此方法
var lastDate = new Date(today.getFullYear(), today.getMonth() + 1, 0);
终于
var today = new Date(); //Get today's date
var lastDate = new Date(today.getFullYear(), today.getMonth() + 1, 0); //To get the last date of today's month
$("#datepicker").datepicker({
startDate: today,
endDate: lastDate
});
JSFiddle
关于jquery - 仅在 Bootstrap Datepicker 中将日期选择限制为非过去的月份,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20086648/