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.
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
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.
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
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.
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
Copy link to clipboard
Copied
Just crap the BC date picker Dean and use one of many jQuery or xxx plugins out there.
Copy link to clipboard
Copied
Ok thanks Liam, I'll take a look and find something that will work.