Making html5 input field of type "datetime-local" compatible with Firefox
Better than detecting the browser itself is to detect whether the browser and version are compatible to some input type or not.
Fortunately, there are some easy ways of doing this. I like to use Modernizr.
The code below shows how to test if the browser supports datetime-local
using Modernizr and if it is not supported, applies jQuery.ui plug-in called datetimepicker
:
<script> <!-- if(!Modernizr.inputtypes['datetime-local']) { $('input[type=datetime-local]').datetimepicker(); } --></script>