最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jqueryui datepicker not showing all years in range - Stack Overflow

programmeradmin5浏览0评论

. Hello,

I'm using jqueryui's datepicker, and it works great but there's a problem. The list of year is not complete, for example it only show 10 years. If I want to go 10 years back I have to click on the first year and then click again to select one year

This are my settings:

    $.datepicker.setDefaults( $.datepicker.regional["es"] );
    $("#birth_date").datepicker(
    {
        shortYearCutoff: 1,
        changeMonth: true,
        changeYear: true,
        dateFormat: 'dd-mm-yy',
        minDate: "-70Y", 
        maxDate: "-15Y" 
    });

The first time it show this range 1997 to 1987, if I want to set 1960 then I have to click 2 times and it bothers sometimes.

What I want to know is if theres a way to show the entire year list, from 1942 to 1997

Thanks in advance

Javier

. Hello,

I'm using jqueryui's datepicker, and it works great but there's a problem. The list of year is not complete, for example it only show 10 years. If I want to go 10 years back I have to click on the first year and then click again to select one year

This are my settings:

    $.datepicker.setDefaults( $.datepicker.regional["es"] );
    $("#birth_date").datepicker(
    {
        shortYearCutoff: 1,
        changeMonth: true,
        changeYear: true,
        dateFormat: 'dd-mm-yy',
        minDate: "-70Y", 
        maxDate: "-15Y" 
    });

The first time it show this range 1997 to 1987, if I want to set 1960 then I have to click 2 times and it bothers sometimes.

What I want to know is if theres a way to show the entire year list, from 1942 to 1997

Thanks in advance

Javier

Share Improve this question asked Jun 12, 2012 at 18:14 JavierQQ23JavierQQ23 7141 gold badge8 silver badges21 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 11

You need to use the yearRange option too. MaxDate and MinDate only validates the date chosen. Year range modifies the visible years.

$.datepicker.setDefaults( $.datepicker.regional["es"] );
    $("#birth_date").datepicker(
    {
        shortYearCutoff: 1,
        changeMonth: true,
        changeYear: true,
        dateFormat: 'dd-mm-yy',
        minDate: "-70Y", 
        maxDate: "-15Y",
        yearRange: "1942:1997"
    });

You want to add the year range option:

Demo: http://jsfiddle.net/lucuma/NAuEx/2/

$(document).ready(function() {
    $.datepicker.setDefaults( $.datepicker.regional["es"] );
    $("#birth_date").datepicker(
    {
        shortYearCutoff: 1,
        changeMonth: true,
        changeYear: true,
        dateFormat: 'dd-mm-yy',
        minDate: "-70Y", 
        maxDate: "-15Y",
         yearRange: "1900:2010" 
    });

});
​

Setting a more dynamic range will look like this in your case

yearRange: "-70Y:-15Y" 
发布评论

评论列表(0)

  1. 暂无评论