by gabereiser · 4y ago · 0 comments
Exceptions are a really bad match for marking validation (even ignoring the arsefest that is debugging exceptions during keyboard input events - ugggh).
The DOM has onInvalid events[1] that are fired on form submit (not blur), and there is an :invalid[2] pseudo class for highlighting input errors. Not a perfect API, but certainly relevantly interesting.
[1] https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputEl...
[2] https://developer.mozilla.org/en-US/docs/Web/CSS/:invalid