如何将jQuery日期选择器限制为仅当月? [英] how to restrict jquery date picker to only current month?
本文介绍了如何将jQuery日期选择器限制为仅当月?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将日期选择器设置为仅显示当前月份,并且用户不能移动到前几个月或下个月.是否有内置功能?
I want to set the date-picker to show only the current month and user cannot move to previous months or next months.Is there any in build function for it?
推荐答案
如此使用datapiker:
Use datapiker so:
// temp vars used below
var currentTime = new Date()
var minDate = new Date(currentTime.getFullYear(), currentTime.getMonth(), +1); //one day next before month
var maxDate = new Date(currentTime.getFullYear(), currentTime.getMonth() +2, +0); // one day before next month
$( "#datepicker" ).datepicker({
minDate: minDate,
maxDate: maxDate
});
文档: http://jqueryui.com/demos/datepicker/#min-max
这篇关于如何将jQuery日期选择器限制为仅当月?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文