datepicker限制当前年 [英] datepicker limit current year
本文介绍了datepicker限制当前年的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经尝试过这种模式,但箭头可以到2012年或2014年,例如:
$('#check-in')。datepicker({dateFormat:'dd-mm',changeYear:false,yearRange:-0: +0,stepYears:0});
解决方案
设置 minDate
和 maxDate
像
$(function()
var year =(new Date).getFullYear();
$(#datepicker).datepicker({
minDate:new Date(year,0,1),
maxDate:new Date(year,11,31)
});
});
I have a little problem with datepicker, I'd want that a user with arrows can only select a date between the first day of the first month and the last day of the month, but it would be dynamic because if we are in 2014 I have to see only year of 2014.
I have tried in this mode but with arrows I can go to 2012 or 2014 for example:
$('#check-in').datepicker({ dateFormat: 'dd-mm', changeYear: false, yearRange: "-0:+0", stepYears: 0 });
解决方案
Set minDate
and maxDate
like
$(function() {
var year = (new Date).getFullYear();
$( "#datepicker" ).datepicker({
minDate: new Date(year, 0, 1),
maxDate: new Date(year, 11, 31)
});
});
这篇关于datepicker限制当前年的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文