Blog
Chan : Html 4 / 5 Date Input Autodetection
07 Dec 2009 | 0 Comments | Permalink
The proof-of-concept browser capability detection code has been pulled into Chan's development trunk. Essentially this is an xml file containing a bunch of regular expressions that are run against the User Agent string to determine what the user is, well, using. It's lightweight and aware that the user can bugger the UA up so defaults to assuming you're at least capable of full HTML4 + JS support but also allows for both Mobile (less capable) browsers and granular resolution of what Html 5 features a browser supports.
What this means in practise is that if the RegExp sees "Opera/" in the string it assumes that you have a version that can natively support the Html 5 Date Input. It then double checks the version number with 5 through 8 overriding this. This means that you would not need to update the xml file when Opera 11 comes out, unlike MS's browsercaps system which is somewhat clunky and in practise works in the opposite direction.
Anyway, i've teased you for too long, here is a screenshot of (left to right) Firefox 3 with Javascript disabled, IE8 running normally and Opera 10. Each is showing the exact same page, and each has been automatically served a different Date input. The NoScript one, one with a javascript powered date picker and a native Html 5 <input type="date">, respectively. Click to enlarge: