0

我使用 jQuery datepicker 并且需要一个带有年份选择元素的选项。这是我的元素的代码:

$("#geburtsdatum").datepicker({
    "yearRange":"2000:2010",
    "firstDay":1,
    "dayNamesMin":["So","Mo","Di","Mi","Do","Fr","Sa"],
    "monthNames":["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"],
    "dateFormat":"dd.mm.yy"});

但是我错过了我的日期选择器中的选择。有谁知道我做错了什么?(我正在使用 jquery-1.7.1。)

我的日期选择器

4

3 回答 3

3

您需要添加“changeYear”选项。请参阅此处文档页面上的源代码。

于 2012-04-27T15:16:54.223 回答
2

您的代码应如下所示

$("#geburtsdatum").datepicker({
yearRange: "2000:2010",
firstDay: 1,
dayNamesMin: ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"],
monthNames: ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"],
dateFormat: "dd.mm.yy",
changeYear: true
});​

这是它的一个工作小提琴:http: //jsfiddle.net/pratik136/WByxq/

于 2012-04-27T15:19:02.740 回答
1

我就是这样做的:

$(".datefield").datepicker({
    minDate: (new Date(1920, 0, 1)),
    maxDate: "+100Y",
    yearRange: '1920:2020',
    changeMonth: true,
    changeYear: true,
    onSelect: function() { $(this).valid(); }
});
于 2012-04-27T15:18:35.610 回答