Get the placeholder text of a text field:
var x = document.getElementById("myText").placeholder;
Click the button to display the placeholder text of the text field.
<!DOCTYPE html> <html> <body> First Name: <input type="text" id="myText" placeholder="Name"> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from w w w . j av a2 s . c om var x = document.getElementById("myText").placeholder; document.getElementById("demo").innerHTML = x; } </script> </body> </html>