Form Events in JavaScript

From the DOM Manipulation cheat sheet · Forms · verified Jul 2026

Form Events

Handle form-specific events for validation and interaction

javascript
// Form events
form.addEventListener('submit', handleSubmit)
form.addEventListener('reset', handleReset)

// Input events
input.addEventListener('input', handleInput)     // On every change
input.addEventListener('change', handleChange)   // On blur if changed
input.addEventListener('focus', handleFocus)
input.addEventListener('blur', handleBlur)

// Validation events
input.addEventListener('invalid', handleInvalid)
💡 input event for real-time, change for final value
📌 focusin/focusout bubble, focus/blur don't
⚠️ Prevent invalid event to show custom messages
✅ Debounce validation for better performance

More JavaScript tasks

Back to the full DOM Manipulation cheat sheet