submit Event
noun
say it: “sub-MIT ih-VENT” /səbˈmɪt ɪˈvɛnt/
The event a form fires when it is sent, by its button or the Enter key.
What is submit Event in JavaScript?
submit Event — The event a form fires when it's sent, by its submit button or by Enter in a field. Listen on the form, not the button, and call preventDefault() to handle it with JavaScript instead of loading a new page.
document.getElementById("order-form").addEventListener("submit", event => {
event.preventDefault();
sendOrder();
});
In a sentence
- “Our submit listener calls preventDefault() and sends the order with fetch.”
Level: Apprentice · More JavaScript terms at this level
Updated