HTML DOM Input Number Object
Input Number Object
The Input Number object is new in HTML5.
The Input Number object represents an HTML <input> element with type="number".
Note:Internet Explorer 9 and earlier IE versions do not support <input> elements with type="number".
Access the Input Number Object
You can use the getElementById() method to access an <input> element with type="number":
var x = document.getElementById("myNumber");
Try it Yourself
Tip:You can also, via the form'selementscollection, access the Input Number object.
Create an Input Number Object
You can use the document.createElement() method to create an <input> element with type="number":
var x = document.createElement("INPUT");
x.setAttribute("type", "number"); Try it Yourself
x.setAttribute("type", "number"); Try it Yourself
Input Number Object Properties
| Property | Description |
|---|---|
| autocomplete | Sets or returns the autocomplete attribute value 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 disabled. |
| form | Returns a reference to the form that contains the number field. |
| labels | Returns a list of label elements associated with the number field. |
| list | Returns a reference to the datalist that contains the number field. |
| max | Sets or returns the max attribute value of the number field. |
| min | Sets or returns the min attribute value of the number field. |
| name | Sets or returns the name attribute value of the number field. |
| placeholder | Sets or returns the placeholder attribute value 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 step attribute value of the number field. |
| type | Returns the form element type of the number field. |
| value | Sets or returns the value attribute value of the number field. |
Standard Properties and Events
The Input Number object also supports standardpropertiesandevents。
Related Articles
HTML Tutorial:HTML Forms
HTML Reference:HTML <input> Tag
HTML Reference:HTML <input> type Attribute
Other Extensions