<input> - number
HTML DOM Input Number object
InputNumber object
The Input Number object is new in HTML5.
Input Number objects represent HTML <input> elements with type="number".
Note: Internet Explorer 9 and earlier versions of IE do not support <input> elements with the type="number" attribute.
Access the Input Number object
You can use the getElementById() function to access <input> elements with the type="number" attribute:
var x = document.getElementById("myNumber");
Tip: You can also access the Input Number object through the form's elements collection.
Create an InputNumber object
You can use the document.createElement() method to create an <input> element with the type="number" attribute:
var x = document.createElement("INPUT");
x.setAttribute("type", "number");
Input Number Object Attributes
Attribute | Description |
---|---|
autocomplete | Sets or returns the value of the autocomplete attribute of the number field |
autofocus | Sets or returns whether the number field automatically gets the focus after the page loads |
defaultValue | Set or return the default value of the number field |
disabled | Sets or returns whether the number field is available |
form | Returns a form reference using the number field |
labels | Returns a list of label elements for the number field |
list | Returns a datalist reference containing the number field |
max | Sets or returns the value of the max attribute of the number field |
min | Sets or returns the value of the min property of the number field |
name | Sets or returns the value of the name attribute of the number field |
placeholder | Sets or returns the value of the placeholder property of the number field |
readOnly | Sets or returns whether the number field is read-only |
required | Sets or returns whether the number field is required in the form |
step | Sets or returns the value of the step attribute of the number field |
type | Returns the form element type of the number field |
value | Sets or returns the value of the value attribute of the number field |
Standard Properties and Events
Input Number objects also support standard properties and events .
Related articles
HTML Tutorial: HTML Forms
HTML Reference Manual: HTML <input> Tag
HTML Reference Manual: HTML <input> type attribute