Javascript Reference - HTML DOM Input Reset value Property








The value property sets or gets the value attribute of the reset button.

The value attribute sets the text that is displayed on the reset button.

Browser Support

value Yes Yes Yes Yes Yes

Syntax

Return the value property.

var v = resetObject.value 

Set the value property.

resetObject.value=text




Property Values

Value Description
text The text displayed on the reset button

Return Value

A String type value representing the text displayed on the reset button.

Example

The following code shows how to get the text displayed on a Reset button.


<!DOCTYPE html>
<html>
<body>
<!--   ww w  . j  av a 2  s  . c o  m-->
<input type="reset" id="myReset" value="Reset form">
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {
    var x = document.getElementById("myReset").value;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The code above is rendered as follows:





Example 2

The following code shows how to change the text displayed on a Reset button.


<!DOCTYPE html>
<html>
<body>
<!--from  w ww .  ja v a  2  s.  c om-->
<input type="reset" id="myReset" value="Reset form">
<button onclick="myFunction()">test</button>

<script>
function myFunction() {
    document.getElementById("myReset").value = "newResetButtonValue";
}
</script>

</body>
</html>

The code above is rendered as follows: