Skip to content
Related Articles

Related Articles

How to reset all form values using a button in HTML ?

View Discussion
Improve Article
Save Article
  • Last Updated : 30 Jun, 2021
View Discussion
Improve Article
Save Article

You can easily reset all form values using the HTML button using <input type=”reset”> attribute. Clicking the reset button restores the form to its original state (the default value) before the user started entering values into the fields, selecting radio buttons, checkboxes, etc. There could be many scenarios. 

In this article, we are going to learn about how to clear the input field.

Syntax:

<input type="reset">

Example:

HTML




<!DOCTYPE html>
<html>
  
<body>
    <center>
        <h1 style="color: green;">
            GeeksforGeeks
        </h1>
          
        <form>
            <input type="text" 
                placeholder="Email address" 
                id="email" name="email" />
            <br /><br />
  
            <input type="password" 
                placeholder="Password" id="pin" 
                name="password" maxlength="8" />
            <br /><br />
  
            <input type="reset" value="Reset" 
                style="background-color: red; 
                        color: white" />
            <input type="submit" value="Submit" 
                style="background-color: green; 
                        color: white" />
        </form>
    </center>
</body>
  
</html>

Output:


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!