HTML DOM Input Number Object
Input Number Object
The Input Number object is new in HTML5.
The Input Number object represents an HTML element using type="number" .
Note: Internet Explorer 9 and earlier versions do not support the HTML using the type="number" attribute .
Accessing the Input Number Object
You can use the getElementById() function to access the one using the type="number" attribute element:
var x = document.getElementById("myNumber");
Try it
Tip: You can also access the Input Color object through a form'sElementcollection to access the Input Number object.
Creating the Input Number Object
You can use the document.createElement() method to create the one using the type="number" attribute element:
var x = document.createElement("INPUT");
x.setAttribute("type", "number");
Try it
Input Number Object Properties
| property | 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 focus after the page loads |
| defaultValue | Sets or returns the default value of the number field |
| disabled | Sets or returns whether the number field is available |
| form | Returns a reference to the form that uses the number field |
| labels | Returns the list of label elements of the number field |
| list | Returns a reference to the datalist 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 attribute 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 attribute of the number field |
| readOnly | Sets or returns whether the number field is read-only |
| required | Sets or returns whether the number field is a required field 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
The Input Number object also supports the standard property and Events.
Related Articles
HTML Tutorial: HTML Forms
HTML Reference Manual: HTML tag
HTML Reference Manual: HTML type Attribute