The standard datepicker that is rendered when an <apex:inputField />
component is bound to an sObject field of type Date
or DateTime
has a limited range of years available, as shown in the following screenshot:
While this range of years may be suitable for opportunity close dates, it is unsuitable for capturing a contact's date of birth. One option to improve this is to add some JavaScript to the page that alters the datepicker year range, but this entails a risk as it relies on the standard datepicker code to remain the same.
In this recipe, we will integrate a third-party JavaScript datepicker with a Visualforce input field bound to a date. The datepicker used is from Design2Develop and can be downloaded from http://www.design2develop.com/calendar/. This has been chosen as the style class names; do not conflict with any standard Salesforce style classes as of the Summer 13 release of Salesforce.