Skip to content
Related Articles

Related Articles

Improve Article

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

  • Last Updated : 30 Jun, 2021
Geek Week

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:

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.




My Personal Notes arrow_drop_up
Recommended Articles
Page :