Categories
JavaScript Answers

How to reset (clear) form through JavaScript?

Spread the love

Sometimes, we want to reset (clear) form through JavaScript.

In this article, we’ll look at how to reset (clear) form through JavaScript.

How to reset (clear) form through JavaScript?

To reset (clear) form through JavaScript, we call the form element’s reset method.

For instance, we write

document.forms["frm_id"].reset();

to get the form with ID frm_id with document.forms["frm_id"].

Then we call reset to clear the values in the form.

Conclusion

To reset (clear) form through JavaScript, we call the form element’s reset method.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *