form invalid event

For the more technical/geeky chat subjects!

Moderator: satrow

pmuser2
Moongazer
Moongazer
Posts: 10
Joined: Fri, 09 Feb 2018, 04:35

form invalid event

Unread postby pmuser2 » Sat, 16 Jun 2018, 22:43

In HTML 5, 4.10 Forms — 4.10.1.4 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>
<script>
document.forms[0].addEventListener ('invalid', function (ev)
{
   console.log (ev.target);
}, true);
</script>

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.)

Return to “Technical chat”

Who is online

Users browsing this forum: No registered users and 3 guests