Join the AI Workshop and learn to build real-world apps with AI. A hands-on, practical program to level up your skills.
A common need is to reset a form to its initial state. You can use a reset button or call reset() from JavaScript.
A reset button is an <input type="reset" />:
<input type="reset" />
To reset a form from JavaScript, get the form element and call reset():
const form = document.querySelector('form')
form.reset()
This restores all form fields to their initial values.