
- 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 placeholder property
The HTML DOM Input Password placeholder property is used for setting or returning the placeholder attribute value of an input password field. The placeholder property is used for giving the web page users a hint about the input element by showing a text inside the input field befor the user inputs anything. The placeholder text is greyed by default and isn’t submitted to the form unlike the value property.
Syntax
Following is the syntax for −
Setting the placeholder property −
passwordObject.placeholder = text
Here, text represents the placeholder text specifying the hint for the user about the password field.
Example
Let us look at an example for the input Password placeholder property −
<!DOCTYPE html> <html> <body> <h1>password placeholder property</h1> Password: <input type="password" id="PASS1" placeholder="...."> <p>Change the placeholder text of the above field by clicking the below button</p> <button onclick="changeHolder()">CHANGE</button> <script> function changeHolder() { document.getElementById("PASS1").placeholder = "Enter your password here.."; } </script> </body> </html>
Output
This will produce the following output −
On clicking the CHANGE button −
In the above example −
We have first created an input password field with id “PASS1” and placeholder attribute value set to “….”.
Password: <input type="password" id="PASS1" placeholder="....">
We then created a button CHANGE that will execute the changeHolder() method when clicked by the user −
<button onclick="changeHolder()">CHANGE</button>
The changeHolder()uses the getElementById() method to get the input element with type password. It then set its placeholder property value to “Enter your password here..” which is reflected in the password field −
function changeHolder() { document.getElementById("PASS1").placeholder = "Enter your password here.."; }
- Related Articles
- HTML DOM Input Number placeholder Property
- HTML DOM Input Email placeholder Property
- HTML DOM Input URL placeholder Property
- HTML DOM Input Search placeholder property
- HTML DOM Input Text placeholder property
- HTML DOM Input Password value property
- HTML DOM Input Password pattern property
- HTML DOM Input Password readOnly property
- HTML DOM Input Password required property
- HTML DOM Input Password size property
- HTML DOM Input Password type property
- HTML DOM Input Password autofocus Property
- HTML DOM Input Password defaultValue Property
- HTML DOM Input Password disabled Property
- HTML DOM Input Password form Property
