以下设置适用于IE9-,Chrome和FireFox。
为什么IE8无法使用值加载年份下拉列表?
$(document).ready(function(){
var now = new Date('2014,01,08');
var maxDate = new Date(now.getUTCFullYear() - 18, now.getUTCMonth(), now.getUTCDate());
var minDate = new Date(now.getUTCFullYear() - 99, now.getUTCMonth(), now.getUTCDate());
$('.birthdateDatePicker').datepicker({
changeMonth: true,
changeYear: true,
yearRange: '-99:-18',
dateFormat: 'yy/mm/dd',
minDate: minDate,
maxDate: maxDate,
showOn: 'button',
buttonText: '',
buttonImage: '/media/7772/schedule_16.png',
buttonImageOnly: true,
onSelect: function () {
this.fireEvent && this.fireEvent('onchange') || $(this).change();
},
});
$('.birthdateDatePicker').attr('readonly', 'readonly');
});
答案 0 :(得分:1)
解决方案:
minDate和maxDate似乎在IE8中不起作用。
将代码更改为:
..
minDate: "-99y",
maxDate: "-18y",
..