googlearchive / core-input

A single-line text field with some extra powers
7 stars 20 forks source link

Feature request: events when validation changes #55

Open jklein24 opened 9 years ago

jklein24 commented 9 years ago

The old input-valid and input-invalid events were pretty useful, but they're gone now. Is there any reason we can't put them back in?

ssorallen commented 9 years ago

Input validity seems to be covered well by native APIs. By default and according to the spec, validity of inputs is checked only when the hosting <form> is submitted. You can call checkValidity directly on an input element to check if its current value is valid outside when the hosting form is submitted, and an "invalid" event is fired if the input is invalid when that method is called.

ssorallen commented 9 years ago

The anecdotal reasoning behind checking validity only on submit is that it's not possible to assert a user is done editing input until the user tries to submit the form. You can possibly infer that blurring an input field is an assertion of validity, but that's not always true.