HTML - attributes - onreset

revision:


Content

"onreset" attribute : when a form is reset syntax some examples


"onreset" attribute : when a form is reset

top

The onreset event occurs when a form is reset.

Supported HTML tags: <form>


syntax

top

<element onreset="script"></element>

script: this attribute contains a "single value script", which works when the onreset event attribute is called.


some examples

top

When you reset the form, a function is triggered which alerts some text.

Enter name:

codes:
                    <p class="spec">When you reset the form, a function is triggered
                    which alerts some text.</p>
                    <form style="margin-left:3vw;" onreset="resetFunction()">
                        <p class="spec">Enter name: <input type="text"></p>
                        <input type="reset">
                    </form>
                    <script>
                        function resetFunction() {
                        alert("The form was reset");
                        }
                    </script>
                

When you reset the form, a function is triggered which outputs some text.

enter name:

codes:
                    <p class="spec">When you reset the form, a function is triggered
                    which outputs some text.</p>
                    <form style="margin-left:3vw;" onreset="formReset()">
                        <p class="spec">enter name: <input type="text"></p>
                        <input type="reset">
                    </form>
                    <p class="spec" id="demo"></p>
                    <script>
                        function formReset() {
                        document.getElementById("demo").innerHTML = "The form was reset";
                        }
                    </script>