简体   繁体   中英

How to change the range of dates which are shown in datepicker jQuery UI?

For example, this is an example of how one would show the year and month menus:

$("#datepicker").datepicker({
    changeMonth: true,
    changeYear: true
});

But this only shows 21 dates, 10 up and 10 down (for example, 2002 - 2022). But that isn't enough for me, as I want people's birth dates. So, can I increase that range to, for example, (1952 - 2008), as I don't want people giving dates past the current year?

If you take a look at the jquery api documentation , it says that you can initialize jquery datepicker using the following parameter.

$( ".selector" ).datepicker({ yearRange: "2002:2012" });

I hope that helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM