Reset a Form using JavaScript

Posted by I. B. Gd Pramana A. Putra, 07 Aug 22, last updated 07 Aug 22

To reset a form with JavaScript, we can use reset() method.

This is the example of how to reset a form using JavaScript:

<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title>Reset Form Using jQuery</title>
<script src=""></script>
function resetForm() {
    <form action="/action.php" method="post" id="ourForm">
        <label>First Name:</label>
        <input type="text" name="first-name">
        <input type="submit" value="Submit">
    <button type="button" onclick="resetForm();">Custom Reset Button</button>

I love sharing code snippets as most of the time, a quick code example is what we're looking for instead of long-written articles. If you think my code snippets are helpful and save you a lot of time, please consider buying me a cup of coffee :)

Support me via · paypal · buymeacoffee · ko-fi · trakteer
Contributed Snippets
Answer & Responses
    No comments yet

Wanna write a response?

You have to login before write a comment to this post.