Date Picker Year Range?

Permalink
The date picker, when added to a form, only shows the last 10 years.

When asking for a birthdate, this field is pretty much impossible to fill out unless you know that you can type a date into the box.

I found this thread here:

http://www.concrete5.org/community/forums/customizing_c5/datepicker...

But the info seems to be outdated, since the file referenced in that thread now only has two lines of code in it.

How can I change the default range of the Year dropdown in the Date/Time picker?

Thanks!

leinteractive
View Replies:
shahroq replied on at Permalink Reply
shahroq
The default year range of jQuery UI is "c-10:c+10". it means 10 year before now to 10 years later. (http://api.jqueryui.com/datepicker/#option-yearRange)
for changing the behavior open file:
\concrete\core\helpers\form\date_time.php and in line 146 replace this line:
$html .= '<script type="text/javascript">$(function() { $("#' . $id . '_dt").datepicker({ dateFormat: \'' . DATE_APP_DATE_PICKER . '\', changeYear: true, showAnim: \'fadeIn\' }); });</script>';

With:
$html .= '<script type="text/javascript">$(function() { $("#' . $id . '_dt").datepicker({ dateFormat: \'' . DATE_APP_DATE_PICKER . '\', changeYear: true, showAnim: \'fadeIn\', yearRange: \'c-100:c\' }); });</script>';


and also replace this at line 205:
$html .= '<script type="text/javascript">$(function() { $("#' . $id . '").datepicker({ dateFormat: \'' . DATE_APP_DATE_PICKER . '\', changeYear: true, showAnim: \'fadeIn\' }); });</script>';

With:
$html .= '<script type="text/javascript">$(function() { $("#' . $id . '").datepicker({ dateFormat: \'' . DATE_APP_DATE_PICKER . '\', changeYear: true, showAnim: \'fadeIn\', yearRange: \'c-100:c\' }); });</script>';
cjramki replied on at Permalink Reply
cjramki
Hi shahroq,

I tried this, but no reflection...
gmatik replied on at Permalink Reply
gmatik
Works for me. Thanks.
3hawk replied on at Permalink Reply
3hawk
It worked for me too - thanks! It worked for c-100:c\ but want to limit it to 10 years ago. I tried c-100:c-10\ and it still shows 2014 as the year. I would like it to show 2004 as the latest year, to call the year entry to people's attention.