Skip navigation
Currently Being Moderated

Customise date picker years

Jul 22, 2012 3:10 AM

Tags: #forms #web_forms #webforms

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

 
Replies
  • Currently Being Moderated
    Jul 22, 2012 4:28 PM   in reply to Fubals

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 23, 2012 5:19 AM   in reply to Fubals

    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

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points