
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML DOM Input Number type Property
The HTML DOM Input number type property is associated with the input element having its type=”number”. It will always return number for the input number element.
Syntax
Following is the syntax for number type property −
numberObject.type
Example
Let us look at an example for the HTML DOM Input Number type property −
<!DOCTYPE html> <html> <body> <h1>Input Number type property</h1> PHONE NO: <input type="number" id="NUMBER1"> <p>Get the above element type by clicking the below button</p> <button onclick="getType()">Get Type</button> <p id="Sample"></p> <script> function getType() { var t = document.getElementById("NUMBER1").type; document.getElementById("Sample").innerHTML = "The type for the input field is : "+t; } </script> </body> </html>
Output
This will produce the following output −
On clicking the “Get Type” button −
In the above example −
We have created an input field with type number and its id set to “NUMBER1”.
PHONE NO: <input type="number" id="NUMBER1">
We have then created the “Get Type” button that will execute the getType() method when clicked by the user −
<button onclick="getType()">Get Type</button>
The getType() method gets the input element using the getElementById() method and assigns its type attribute value to variable t. This variable is then displayed in the paragraph with id “Sample” using its innerHTML property −
function getType() { var t = document.getElementById("NUMBER1").type; document.getElementById("Sample").innerHTML = "The type for the input field is : "+t; }
- Related Articles
- HTML DOM Input Button type Property
- HTML DOM Input FileUpload type Property
- HTML DOM Input Hidden type Property
- HTML DOM Input Month type Property
- HTML DOM Input Password type property
- HTML DOM Input Radio type property
- HTML DOM Input Range type property
- HTML DOM Input Checkbox type Property
- HTML DOM Input Color type Property
- HTML DOM Input Date type Property
- HTML DOM Input Datetime type Property
- HTML DOM Input DatetimeLocal type Property
- HTML DOM Input Email type Property
- HTML DOM Input Text type Property
- HTML DOM Input Time type Property
