Input Email placeholder Attribute
Example
Modify the placeholder text for the email field:
document.getElementById("myEmail").placeholder = "Your Email address";
Definition and Usage
The placeholder attribute is used to set or return the value of the placeholder attribute of an email field.
The placeholder attribute provides a hint describing the expected value of an input field.
This hint is displayed in the input field when it is empty and disappears when the field gains focus.
Browser Support
All major browsers support the placeholder attribute.
Note: Internet Explorer 9 and earlier versions do not support the placeholder attribute.
Syntax
Return the placeholder attribute:
Set the placeholder attribute:
Attribute Values
| Value | Description |
|---|---|
| text | A hint describing the expected value of the input field |
Technical Details
| Return Value: | String, representing the hint for the expected value of the input field | | --- | --- |
More Examples
Example
Get the placeholder text for the email field:
var x = document.getElementById("myEmail").placeholder;
x outputs:
Email
Related Pages
HTML Reference: HTML <input> placeholder Attribute