FREE Web Template Download
HTML CSS JAVASCRIPT SQL PHP BOOTSTRAP JQUERY ANGULARJS TUTORIALS REFERENCES EXAMPLES Blog
 

Input Text placeholder Property

Input Text Object Reference Input Text Object

Example

Change the placeholder text of a text field:

document.getElementById("myText").placeholder = "Type name here..";
Try it Yourself »

Definition and Usage

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

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

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


Browser Support

Property
placeholder Yes 10.0 Yes Yes Yes

Syntax

Return the placeholder property:

textObject.placeholder

Set the placeholder property:

textObject.placeholder=text

Property Values

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

Technical Details

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

More Examples

Example

Get the placeholder text of a text field:

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

The result of x will be:

Name
Try it Yourself »

Related Pages

HTML reference: HTML <input> placeholder attribute


Input Text Object Reference Input Text Object