1. Computing

Discuss in my forum

<input type="number">

By

input type=number in Opera

input type=number in Opera

Screen shot by J Kyrnin

INPUT Number Description:

The number INPUT tag allows you to request a numerical value in your form. Browsers that support it should display some type of numerical sequence that makes it clear that a number is expected in this input field. By using the min and max attributes, web developers can control the input. By default, the browser will display a select box with just positive and negative integers and zero. To request fractional values, you should include a min or max value that is not an integer (such as 1.5) or set the step attribute to something larger or smaller than 1 (the default), such as 0.5.

DTD: HTML5: <!doctype html>

INPUT Number Web Browser Support:

At this time, only Opera 9+ supports the INPUT number type with a selection box (see screen shot above). All other browsers display a text box. You can still use this input type, you will just have to validate that the contents are a number with a script or CGI.

HTML Versions

INPUT Number Attributes:

Global attributes, event attributes, and the input tag attributes. Plus: </p>

  • autocomplete
  • list
  • max
  • min
  • readonly
  • required
  • step
  • valueAsNumber
  • selectedOption
  • stepDown()
  • stepUp()

INPUT Number Usage:

Standard number input tag

<form>
<input type="number">
</form>

See an example of a standard number input tag.

INPUT Number Special Notes:

The input number tag is only supported in Opera 9+ if you want a select box displayed, but you can still use this input type and validate that the submitted data is a number. That way, when other browsers do start supporting it, your forms won't have to be modified.

More INPUT Number Information:

  1. About.com
  2. Computing
  3. Web Design / HTML
  4. HTML and XHTML
  5. HTML 5
  6. HTML 5 Tags
  7. The INPUT Number Tag - INPUT Number - HTML Tag for Numbers

©2014 About.com. All rights reserved.