
- 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 Password type property
The HTML DOM Input password type property is associated with the input element having its type=”password”. It will always return password for the input password element.
Syntax
Following is the syntax for password type property −
passwordObject.type
Example
Let us look at an example for the Input password type property −
<!DOCTYPE html> <html> <body> <h1>password type property</h1> PASSWORD: <input type="password" id="PASS1"> <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("PASS1").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 password and its id set to “PASS1”.
PASSWORD: <input type="password" id="PASS1">
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("PASS1").type; document.getElementById("Sample").innerHTML = "The type for the input field is : "+t; }
- Related Articles
- HTML DOM Input Password autofocus Property
- HTML DOM Input Password defaultValue Property
- HTML DOM Input Password disabled Property
- HTML DOM Input Password form Property
- HTML DOM Input Password maxLength Property
- HTML DOM Input Password name Property
- HTML DOM Input Password value property
- HTML DOM Input Password pattern property
- HTML DOM Input Password placeholder property
- HTML DOM Input Password readOnly property
- HTML DOM Input Password required property
- HTML DOM Input Password size property
- HTML DOM Input Time type Property
- HTML DOM Input URL type Property
- HTML DOM Input Week type Property
