HTML DOM Input Password placeholder Property
THE WORLD'S LARGEST WEB DEVELOPER SITE

Input Password placeholder Property

❮ Input Password Object

Example

Change the placeholder text of a password field:

document.getElementById("myPassword").placeholder = "Type your password";
Try it Yourself »

Definition and Usage

The placeholder property sets or returns the value of the placeholder attribute of a password field.

The placeholder attribute specifies a short hint that describes the expected value of a password field (e.g. a sample value or a short description of the expected format).

The short hint is displayed in the password field before the user enters a value.


Browser Support

Property
placeholder Yes 10.0 Yes Yes Yes

Syntax

Return the placeholder property:

passwordObject.placeholder

Set the placeholder property:

passwordObject.placeholder = text

Property Values

Value Description
text Specifies a short hint (one word or a short phrase) that describes the expected value of the password field

Technical Details

Return Value: A String, representing a short hint that describes the expected value of the password field

More Examples

Example

Get the placeholder text of a password field:

var x = document.getElementById("myPassword").placeholder;
Try it Yourself »

Related Pages

HTML reference: HTML <input> placeholder attribute


❮ Input Password Object