Skip to main content

How to reset an HTML form on submit using JavaScript

·53 words·1 min·
Javascript Form Dom
Joseph Ochego
Author
Joseph Ochego
Self-taught Web Developer | Linux Enthusiast
Table of Contents

By default html forms are reset and all fields are cleared when we submit them.
However, in instances whereby you use the preventDefault() method in the JavaScript file, the form doesn’t reset automatically.
In such situations, we have to trigger the reset event manually using the following JavaScript method:

document.getElementById("formId").reset();

Links #

https://www.w3schools.com/jsref/met_form_reset.asp

Related

My first post
·84 words·1 min
Hugo Blowfish Blog Write Thoughts Learn