How to get HTML 5 input type="date" working in Firefox and/or IE 10
Use a polyfill like Pikaday or jQuery UI DatePicker to backport HTML5 input type="date"
support for browser veterans like Firefox and IE 10.
Pikaday example:
jQuery UI DatePicker example:
While both snippets offer a quick fix, use the one that seamlessly conforms to your existing scripts and styles.
Up and coming browser support
The route to widespread support
Developments in Firefox 57+ mean input type="date"
is now natively supported, making polyfills redundant in these versions. The Webshims library, however, is still a trusty companion for dealing with elder versions.
Tuning your polyfill for performance
Configure your polyfill with options like waitReady
set to false
for faster loads. Coupled with Modernizr, a feature-detection library, webshim is efficiently loaded only when necessary.
Conforming to site aesthetics and responsive design
Responsive designs and consistent styling for date inputs are essential in UI/UX. Always ensure your datepicker matches your website’s theme and layout.
Practical solutions and alternatives
Quantifying jQuery UI DatePicker
In jQuery UI DatePicker, remember to tweak the dateFormat
to suit your localization requirements. Various formats like mm/dd/yy
for U.S. or dd/mm/yy
for EU can be easily tailored.
Unleashing the webshims arsenal
Turn to Webshims for more complex scenarios. Visit their demo and configurator to customize settings, including date format preferences. Keep the library files updated for ongoing compatibility and new feature access.
The upper hand with Modernizr
Combining Modernizr with webshims works brilliantly for progressive enhancement. Modernizr inspects browser capabilities, loading polyfills only when needed.
Explicit Fall-back strategies
In times of increased UI complexity or unsupported browsers, you might contemplate alternative approaches like custom-built date selectors or using 'input type="text"' along with pattern validation.
Was this article helpful?