HTML <input> Tag with 'type=number'

<form name="myForm" action="">
<input type="number" name="myField" value="12345678">


The above example demonstrates usage of the <input> element with the type attribute set to number (i.e. type="number").

The number value represents a control for setting the element's value to a string representing a number. This is a numerical value. If a value is specified, it must be a valid floating-point number.

Specifying a min and/or max Number

The min and max attributes can be used with the number field to specify a minimum and maximum number. If specified, they must have a value that is a valid floating-point number.

The following example specifies a min value of 100 and a max value of 200. Therefore the user can only select a number that falls within that range.

<form name="myForm2" action="">
<input type="number" min="100" max="200" name="myField2" value="300">


Specifying a step

You can also use the step attribute to limit the numbers the user can choose from.

The following example uses a step value of 2, resulting in every second number being unavailable.

<form name="myForm3" action="">
<input type="number" step="2" name="myField3">