Skip to content

Commit

Permalink
Demix invalid event from GlobalEventHandlers (mdn#18451)
Browse files Browse the repository at this point in the history
  • Loading branch information
queengooborg authored Jul 18, 2022
1 parent 7e27a47 commit fd9ca3c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 130 deletions.
3 changes: 2 additions & 1 deletion files/en-us/_redirects.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8124,7 +8124,7 @@
/en-US/docs/Web/API/GlobalEventHandlers/GlobalEventHandlers.ondurationchange /en-US/docs/Web/API/HTMLMediaElement/durationchange_event
/en-US/docs/Web/API/GlobalEventHandlers/GlobalEventHandlers.onemptied /en-US/docs/Web/API/HTMLMediaElement/emptied_event
/en-US/docs/Web/API/GlobalEventHandlers/GlobalEventHandlers.onended /en-US/docs/Web/API/HTMLMediaElement/ended_event
/en-US/docs/Web/API/GlobalEventHandlers/GlobalEventHandlers.oninvalid /en-US/docs/Web/API/GlobalEventHandlers/oninvalid
/en-US/docs/Web/API/GlobalEventHandlers/GlobalEventHandlers.oninvalid /en-US/docs/Web/API/HTMLInputElement/invalid_event
/en-US/docs/Web/API/GlobalEventHandlers/GlobalEventHandlers.onloadeddata /en-US/docs/Web/API/GlobalEventHandlers/onloadeddata
/en-US/docs/Web/API/GlobalEventHandlers/GlobalEventHandlers.onloadedmetadata /en-US/docs/Web/API/GlobalEventHandlers/onloadedmetadata
/en-US/docs/Web/API/GlobalEventHandlers/GlobalEventHandlers.onloadstart /en-US/docs/Web/API/GlobalEventHandlers/onloadstart
Expand Down Expand Up @@ -8164,6 +8164,7 @@
/en-US/docs/Web/API/GlobalEventHandlers/onfocus /en-US/docs/Web/API/Window/focus_event
/en-US/docs/Web/API/GlobalEventHandlers/onformdata /en-US/docs/Web/API/HTMLFormElement/formdata_event
/en-US/docs/Web/API/GlobalEventHandlers/oninput /en-US/docs/Web/API/HTMLElement/input_event
/en-US/docs/Web/API/GlobalEventHandlers/oninvalid /en-US/docs/Web/API/HTMLInputElement/invalid_event
/en-US/docs/Web/API/GlobalEventHandlers/onkeydown /en-US/docs/Web/API/Element/keydown_event
/en-US/docs/Web/API/GlobalEventHandlers/onkeypress /en-US/docs/Web/API/Element/keypress_event
/en-US/docs/Web/API/GlobalEventHandlers/onkeyup /en-US/docs/Web/API/Element/keyup_event
Expand Down
11 changes: 0 additions & 11 deletions files/en-us/_wikihistory.json
Original file line number Diff line number Diff line change
Expand Up @@ -44291,17 +44291,6 @@
"jpmedley"
]
},
"Web/API/GlobalEventHandlers/oninvalid": {
"modified": "2020-10-15T21:44:05.936Z",
"contributors": [
"mfluehr",
"fscholz",
"sideshowbarker",
"wbamberg",
"rolfedh",
"Guillaume-Heras"
]
},
"Web/API/GlobalEventHandlers/onload": {
"modified": "2020-10-15T21:12:46.292Z",
"contributors": [
Expand Down
2 changes: 0 additions & 2 deletions files/en-us/web/api/globaleventhandlers/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ These event handlers are defined on the {{domxref("GlobalEventHandlers")}} mixin
- : An [event handler](/en-US/docs/Web/Events/Event_handlers) for processing {{domxref("HTMLFormElement/formdata_event", "formdata")}} events, fired after the entry list representing the form's data is constructed.
- {{domxref("GlobalEventHandlers.ongotpointercapture")}}
- : An [event handler](/en-US/docs/Web/Events/Event_handlers) representing the code to be called when the {{domxref("HTMLElement/gotpointercapture_event", "gotpointercapture")}} event type is raised.
- {{domxref("GlobalEventHandlers.oninvalid")}}
- : An [event handler](/en-US/docs/Web/Events/Event_handlers) representing the code to be called when the {{domxref("HTMLInputElement/invalid_event", "invalid")}} event is raised.
- {{domxref("GlobalEventHandlers.onload")}}
- : An [event handler](/en-US/docs/Web/Events/Event_handlers) representing the code to be called when the {{domxref("Window/load_event", "load")}} event is raised.
- {{domxref("GlobalEventHandlers.onloadeddata")}}
Expand Down
95 changes: 0 additions & 95 deletions files/en-us/web/api/globaleventhandlers/oninvalid/index.md

This file was deleted.

35 changes: 14 additions & 21 deletions files/en-us/web/api/htmlinputelement/invalid_event/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,24 @@ browser-compat: api.HTMLInputElement.invalid_event

The **`invalid`** event fires when a submittable element has been checked for validity and doesn't satisfy its constraints.

<table class="properties">
<tbody>
<tr>
<th>Bubbles</th>
<td>No</td>
</tr>
<tr>
<th>Cancelable</th>
<td>Yes</td>
</tr>
<tr>
<th>Interface</th>
<td>{{DOMxRef("Event")}}</td>
</tr>
<tr>
<th>Event handler property</th>
<td>{{domxref("GlobalEventHandlers.oninvalid")}}</td>
</tr>
</tbody>
</table>

This event can be useful for displaying a summary of the problems with a form on submission. When a form is submitted, `invalid` events are fired at each form control that is invalid. The validity of submittable elements is checked before submitting their owner {{HtmlElement("form")}}, or after the [`checkValidity()`](/en-US/docs/Learn/Forms#constraint_validation_api) method of the element or its owner `<form>` is called.

It is not checked on {{domxref("Element/blur_event", "blur")}}.

## Syntax

Use the event name in methods like {{domxref("EventTarget.addEventListener", "addEventListener()")}}, or set an event handler property.

```js
addEventListener('invalid', (event) => {});

oninvalid = (event) => { };
```

## Event type

A generic {{domxref("Event")}}.

## Examples

If a form is submitted with an invalid value, the submittable elements are checked and, if an error is found, the `invalid` event will fire on the `invalid` element. In this example, when an invalid event fires because of an invalid value in the input, the invalid value is logged.
Expand Down

0 comments on commit fd9ca3c

Please sign in to comment.