Javascript Form How to - Get form property that contains the Reset button








Question

We would like to know how to get form property that contains the Reset button.

Answer


<!--   w  w w  .  j  av  a  2s  .com-->
<html>
<body>
    <form name="form1">
        Enter Name: <input type="text" Name="name" Size=15>
        <br>
        Enter Phone: <input type="text" Name="phone" Size=10>
        <br><br>
        <input type="reset" name=resetbutton value=Reset
        onClick='console.log("The form name is: " + document.form1.resetbutton.form.name)'>
        <br>
        <br>
    </form>
</body>
</html>

The code above is rendered as follows: