我正在使用月份选择器,希望限制用户只能选择当前及之前的月份和年份。如何实现这个功能?我尝试过:
$("#month").monthpicker({ dateFormat: 'M-yy',
autoSize: true,
changeYear: true,
changeMonth: true,
showButtonPanel: true,
maxDate: new Date().getMonth()
});
但是这样我只能限制未来的年份,而无法限制未来的月份。任何帮助都将不胜感激。
maxDate: new Date()
即可。无需添加.getMonth()
。 - Durgesh Chaudhary