Input Text defaultValue Property - Get the default value of a text field: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Text

Description

Input Text defaultValue Property - Get the default value of a text field:

Demo Code

ResultView the demo in separate window

<!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  ww  w  . j av  a  2  s.c  o m*/
    var x = document.getElementById("myText");
    var defaultVal = x.defaultValue;
    document.getElementById("demo").innerHTML = defaultVal;
}
</script>

</body>
</html>

Related Tutorials