Get the default value of a text field:
var x = document.getElementById("myText").defaultValue;
Click the button to display the default value of the text field.
<!DOCTYPE html> <html> <body> Name: <input type="text" id="myText" value="Mickey"> <button type="button" onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from www . j a v a2 s . com var x = document.getElementById("myText").defaultValue; document.getElementById("demo").innerHTML = x; } </script> </body> </html>