form invalid event

For the more technical/geeky chat subjects!

Moderator: satrow

Posts: 10
Joined: 2018-02-09, 04:35

form invalid event

Unread post by pmuser2 » 2018-06-16, 22:43

In HTML 5, 4.10 Forms — Client-side form validation, there has always been the following note:
"When a form is submitted, invalid events are fired at each form control that is invalid, and then at the form element itself."

But browsers actually fire 'invalid' event only at the form control, not at the form itself. Test document:

Code: Select all

<!doctype html><html lang="en"><meta charset="utf-8"><title>title</title>
<form><input name="name" required><input type="submit"></form>
document.forms[0].addEventListener ('invalid', function (ev)
	console.log (;
}, true);
Do I understand something incorrectly or browsers ignore HTML in aforementioned part?

(By the way, with that example document we can see that console.log () in IE11 and Edge prints closing 'input' tag.)