• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Customise date picker years

Contributor ,
Jul 22, 2012 Jul 22, 2012

Copy link to clipboard

Copied

Is there any way of eliminating / overriding some of the dropdown fields for the years in the date picker on a webform?

The dropdown is massive with years starting from 1920 and going to 2099!!

Its overkill for most scenarios, and also would be good to be able to take out old years as they are over.

date-picker.png

TOPICS
Content management and modules

Views

2.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Employee , Jul 23, 2012 Jul 23, 2012

Here is how you can shorten the "year" list:

-copy the original datepicker javascript here - http://YOURDOMAIN.COM/CatalystScripts/Java_DatePicker.js

-paste it into a new file, say http://YOURDOMAIN.COM/js/DatePicker.js

-search for "1970", you will run across this: for(i=1920;i<=2099;i++)

-change it to for(i=2009;i<=2099;i++) or whatever range you need

-lastly you need to link this modified datepicker js in your page instead of the default one here - http://screencasteu.worldsecuresystems.com/Mihai/2012-07-23_1515.png

Votes

Translate

Translate
New Here ,
Jul 22, 2012 Jul 22, 2012

Copy link to clipboard

Copied

I had the same issue, I wanted to use it for DOB so it was silly to have future years in the options. I ended up going with the jQuery UI datepicker, you can do a lot with its options, limiting years is one thing that can be done see the date picker here http://bit.ly/MUExin. and the jQueryUI can now be split into its elements so its nice and small too.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jul 23, 2012 Jul 23, 2012

Copy link to clipboard

Copied

Here is how you can shorten the "year" list:

-copy the original datepicker javascript here - http://YOURDOMAIN.COM/CatalystScripts/Java_DatePicker.js

-paste it into a new file, say http://YOURDOMAIN.COM/js/DatePicker.js

-search for "1970", you will run across this: for(i=1920;i<=2099;i++)

-change it to for(i=2009;i<=2099;i++) or whatever range you need

-lastly you need to link this modified datepicker js in your page instead of the default one here - http://screencasteu.worldsecuresystems.com/Mihai/2012-07-23_1515.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 23, 2012 Jul 23, 2012

Copy link to clipboard

Copied

@MihaiTica - 5  STARS! That was a very helpful answer. Perfectly executed. It took me all of 2 mins to deploy your solution, well done and thanks so much for the simple step by step method to resolving this.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 01, 2014 Sep 01, 2014

Copy link to clipboard

Copied

Hi MihaiTica,

Is it possible to set a date range with a similar method? For example, if I wanted to restrict the dates from 1st September 2014 - 31st January 2015, can this be done?

Thanks,

Dean

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 01, 2014 Sep 01, 2014

Copy link to clipboard

Copied

Just crap the BC date picker Dean and use one of many jQuery or xxx plugins out there.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 01, 2014 Sep 01, 2014

Copy link to clipboard

Copied

LATEST

Ok thanks Liam, I'll take a look and find something that will work.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines