The reset()
method resets the values of all elements
in a form in the same way as clicking the Reset button.
reset |
Yes | Yes | Yes | Yes | Yes |
formObject.reset()
None.
No return value.
The following code shows how to reset a form.
<!DOCTYPE html>
<html>
<body>
<form id="myForm">
First name: <input type="text" name="fname"><br>
<input type="button" onclick="myFunction()" value="Reset form">
</form><!--from ww w .j av a 2 s. co m-->
<script>
function myFunction() {
document.getElementById("myForm").reset();
}
</script>
</body>
</html>
The code above is rendered as follows: