Modernizr

Contact Us or call 1-877-932-8228
Modernizr

Modernizr

Before we get into HTML5 forms, we will re-introduce you to a great little JavaScript library called Modernizr. Modernizr is used to check the browser for feature support so you can write code like this:

if (Modernizr.xyzFeature) { //do this; } else { //do something different }

We have included it in the html5-common folder in the root of the class files. Here's an example of how you can check for the new email input type:

Code Sample:

html5-forms/Demos/modernizr.html
<!DOCTYPE HTML>
---- C O D E   O M I T T E D ----
<script src="../../html5-common/modernizr.min.js" type="text/javascript"></script>
<script>
	if (Modernizr.inputtypes.email) {
		alert("woohoo!");	
	} else {
		alert("boohoo!");	
	}
</script>
---- C O D E   O M I T T E D ----

To see which HTML5 features it supports, open html5-forms/Demos/modernizr-full-check.html in your browser.

We use modernizr in some of the demos in this lesson.

Next