[html5] regarding to a html5 input type

Jukka K. Korpela jukka.k.korpela at kolumbus.fi
Wed Oct 9 01:18:55 PDT 2013


2013-10-09 10:34, Sandeep Kumar wrote:
> First of all check, does your browser support HTML5.

No browser supports HTML5 (which is a moving target). Some browsers 
support parts of it. The scope of support varies a lot.

> if not ,,, then add *modernizr.js* in your document.
>
Modernizr.js is a feature detection library. It does not add support to 
new input types, for example. Why would using it depend on what an 
author's own browser supports?

Modernizr.js is handy for detecting features without thinking how the 
test should be carried out in detaul. But you have to trust its authors 
then. You should also know that the tests are limited and do not 
actually test conformance to HTML5. For input type=email, the test seems 
to be pretty good: it probably yields true only if there is a reasonable 
attempt at implementing the input type in the browser as per HTML5. The 
documentation is a bit implicit, so here's how to do the test (assuming 
you've downloaded modernizr.js)

<script src=modernizr.js></script>
<script>
if('email' in Modernizr.inputtypes) {
   // code to run when support exists
} else {
   // code to run when no support, e.g. use a library routine for email 
address checking
}
</script>

You might check the list of polyfills at
https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-Browser-Polyfills#web-forms
but I'm afraid it's difficult to find a good email address checker. Most 
such checkers around both reject valid addresses and accept invalid 
addresses. Try to find one that performs just simple tests that rejects 
manifestly wrong input (like input without any "@" character), because 
the main use of such checking is to detect user input that is all wrong 
(e.g., the user typed his name instead).

-- 
Yucca, http://www.cs.tut.fi/~jkorpela/




More information about the Help mailing list