Prevent submit
by Artem
HTML
<form action="">
<input type="text">
<button type="submit">Submit</button>
</form>
JavaScript
document.forms[0].onsubmit = (e) => {
e.preventDefault();
if (document.activeElement instanceof HTMLInputElement) {
console.log('Prevent submit');
} else {
console.log('Submit the form');
}
};