all AI news
How to reset an HTML form on submit using JavaScript
April 17, 2024, 2:03 a.m. | Joseph Ochego
DEV Community dev.to
By default, HTML forms are reset and all fields are cleared when we submit them.
However, in instances where 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
This is a cross-post from the original in my blog site
document dom event fields file form forms however html instances javascript them
More from dev.to / DEV Community
Jobs in AI, ML, Big Data
Data Engineer
@ Lemon.io | Remote: Europe, LATAM, Canada, UK, Asia, Oceania
Artificial Intelligence – Bioinformatic Expert
@ University of Texas Medical Branch | Galveston, TX
Lead Developer (AI)
@ Cere Network | San Francisco, US
Research Engineer
@ Allora Labs | Remote
Ecosystem Manager
@ Allora Labs | Remote
Founding AI Engineer, Agents
@ Occam AI | New York