O'Reilly logo

HTML5 Multimedia Development Cookbook by Lee Jordan, Dale Cruse

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the number tag

HTML5 now allows users to select among a range of numbers. If, for instance, you want your viewers to make a purchase, you'll probably want them to use whole numbers. After all, who orders 2 ½ shoes?

How to do it...

If we continue the shoe-buying example, we could develop a form like this:

<form>
<label>How many shoes would you like to purchase?<label>
<input type="number" name="quantity" min="2" max="6" step="2" value="2" size="4" />
</form>

Notice that in the input, we have optionally specified a minimum number that can be ordered (2) and a maximum that can be ordered (6). Step allows us in this case to make sure users can only order shoes in pairs while value sets the initial number of items displayed. Size then controls ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required