使用 Pickadate.js 日期选择器禁用年份范围
Disabling years range using Pickadate.js date picker
我正在尝试使用 Pickadate.js 更改下拉列表中显示的年份,但无法正常工作。截至目前,年份下拉列表包含我不想看到的年份,包括当前年份。问题是,如何删除年份范围,就像我只想显示年份 1910 - 2012
.
这是我目前拥有的:
$('.datepicker').pickadate({
selectMonths: true,
selectYears: 80,
format: 'yyyy-mm-dd',
formatSubmit: 'yyyy-mm-dd',
max : false,
today: '',
clear: 'Clear Selection',
onStart: function() {
$('.picker__select--month').attr('name', 'month');
$('.picker__day--selected').attr('name', 'day');
$('.picker__select--year').attr('name', 'year');
},
});
根据 docs:
$('.datepicker').pickadate({
min: new Date(1910,1,1),
max: new Date(2012,1,1)
});
如果您可以指定要限制的特定年份的日期。
用数组也不错:
$('.datepicker').pickadate({
min: [1910,1,1],
max: [2012,1,1]
});
你可以试试这个,它会将 1910 年设置为 2012 年 12 月,或者你如何需要动态:
$('.datepicker').pickadate({
selectMonths: true,
selectYears: 200,
format: 'yyyy-mm-dd',
formatSubmit: 'yyyy-mm-dd',
min: new Date(1910,1,1),
max: new Date(2012,11,31),
today: '',
clear: 'Clear Selection',
onStart: function() {
$('.picker__select--month').attr('name', 'month');
$('.picker__day--selected').attr('name', 'day');
$('.picker__select--year').attr('name', 'year');
},
});
我正在尝试使用 Pickadate.js 更改下拉列表中显示的年份,但无法正常工作。截至目前,年份下拉列表包含我不想看到的年份,包括当前年份。问题是,如何删除年份范围,就像我只想显示年份 1910 - 2012
.
这是我目前拥有的:
$('.datepicker').pickadate({
selectMonths: true,
selectYears: 80,
format: 'yyyy-mm-dd',
formatSubmit: 'yyyy-mm-dd',
max : false,
today: '',
clear: 'Clear Selection',
onStart: function() {
$('.picker__select--month').attr('name', 'month');
$('.picker__day--selected').attr('name', 'day');
$('.picker__select--year').attr('name', 'year');
},
});
根据 docs:
$('.datepicker').pickadate({
min: new Date(1910,1,1),
max: new Date(2012,1,1)
});
如果您可以指定要限制的特定年份的日期。
用数组也不错:
$('.datepicker').pickadate({
min: [1910,1,1],
max: [2012,1,1]
});
你可以试试这个,它会将 1910 年设置为 2012 年 12 月,或者你如何需要动态:
$('.datepicker').pickadate({
selectMonths: true,
selectYears: 200,
format: 'yyyy-mm-dd',
formatSubmit: 'yyyy-mm-dd',
min: new Date(1910,1,1),
max: new Date(2012,11,31),
today: '',
clear: 'Clear Selection',
onStart: function() {
$('.picker__select--month').attr('name', 'month');
$('.picker__day--selected').attr('name', 'day');
$('.picker__select--year').attr('name', 'year');
},
});