Home  >  Article  >  Web Front-end  >  JavaScript method to implement reset form (reset)_javascript skills

JavaScript method to implement reset form (reset)_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:06:212031browse

The example in this article describes how to implement reset form (reset) in JavaScript. Share it with everyone for your reference. The details are as follows:

The following code can reset 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 will be helpful to everyone’s JavaScript programming design.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn