/

HTML / CSS / JavaScript Tutorial

HTML Event attribute: onreset

[this page | pdf | back links]

The HTML onreset attribute specifies the event that is triggered when the reset button in a form is clicked. It applies to <form> elements.

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
oninvalid, onreset, onsubmit: try submitting input without entering anything or resetting input:
<form onreset="myOnreset()" onsubmit="myOnsubmit()">
  <input type="text" oninvalid="myOninvalid()" required><input type="submit" value="Submit">
  <input type="reset">
</form>
<br><br><b id="invalidtext"></b><br>

<script>
function myOninvalid() {
  document.getElementById("invalidtext").innerHTML = "Some entry is required";
}
function myOnreset() {alert("Form reset");}
function myOnsubmit() {alert("Form being submitted");}
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | HTML Attributes


Desktop view | Switch to Mobile