Input Email placeholder Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Email field

Description

The placeholder property sets or gets the placeholder attribute of an email field, which provides hint for user.

Set the placeholder property with the following Values

Value Description
text Sets a short hint that describes the expected value of the email field

Return Value

A String, representing a short hint that describes the expected value of the email field

The following code shows how to change the placeholder text of an email field:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>
Login: <input type="email" id="myEmail" placeholder="Email">

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/*from  w  ww.  jav a  2 s . co  m*/
    document.getElementById("myEmail").placeholder = 'new value';
    var x = document.getElementById("myEmail").placeholder;
    document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>

Related Tutorials