Reset() method:
It is used to clear all the values entered in a form. This method does not require any parameter and also does not return any value.
Syntax:
formObject.reset()
Example:
<!DOCTYPE html>
<html>
<body>
<h4>Fill your details</h4>
<form id="loginForm">
<p>User name: <input type="text" name="fname"></p>
<p>Password: <input type="password" name="paswd"></p>
<input type="button" onclick="resetFunc()" value="Reset form">
</form>
<script>
function resetFunc() {
document.getElementById("loginForm").reset();
}
</script>
</body>
</html>
In the above example when a user will click on reset form button , resetFunc() will get called and it will clear all the form values entered by the user
0 Comment(s)