JavaScript implements the method of resetting the form (reset)
- 2020-05-24 05:13:10
- OfStack
This article demonstrates an example of how JavaScript implements a reset form (reset). Share with you for your reference. The details are as follows:
The following code resets the input data in the form
<!DOCTYPE html>
<html>
<head>
<script>
function formReset()
{
document.getElementById("frm1").reset();
}
</script>
</head>
<body>
<p>Enter some text in the fields below,
then press the "Reset form" button to reset the form.</p>
<form id="frm1">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br><br>
<input type="button" onclick="formReset()" value="Reset form">
</form>
</body>
</html>
I hope this article is helpful for you to design javascript program.