Input Password placeholder Attribute

Definition and Usage

placeholder Sets or returns the value of the placeholder attribute of the password field.

The HTML placeholder attribute specifies a brief prompt describing the expected value of the password field (for example, a sample value or a brief description of the expected format).

A brief prompt will be displayed in the password field before the user enters a value.

See also:

HTML Reference Manual:HTML <input> placeholder Attribute

Example

Example 1

Change the placeholder text of the password field:

document.getElementById("myPassword").placeholder = "Please enter your password";

Try it yourself

Example 2

Get the placeholder text of the password field:

var x = document.getElementById("myPassword").placeholder;

Try it yourself

Syntax

Return placeholder attribute:

passwordObject.placeholder

Set placeholder attribute:

passwordObject.placeholder = text

Attribute Value

Value Description
text Specifies a brief hint (word or phrase) for the expected value of the password field.

Technical Details

Return Value: A string value that represents a brief hint of the expected value of the password field.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support 10.0 Support Support Support