Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Proposing to replace default invalid state for form elements by indeterminate #1073
(Please forgive me in advance if some terms are approximate, and feel free to correct me if needed for more relevant naming of states, pseudo-states, pseudo-selectors etc.; I won't be offended the least.)
We (@notabene and @Lausselloic) have a problem with the browser validation occurring on form elements: by default, if a field is
The problem we have is that if we style elements based on the
If I read correctly, the spec in its current state for required does not specify that a field is invalid as of page load. It just says that it is boolean, either true or false. Understandably it's false by default since it's required but was not filled (or checked if it's radio checkboxes). We think that a third indeterminate state should be added, and the browser should, for instance, consider the field as invalid only when one tabs/clicks out of it (AKA when the blur event is triggered) or when one submits the form.
This way a field would not default to being invalid as long as one has not yet interacted with it or its containing form.
By the way, we have the same problem, although a bit less prominent, with patterns: if a field requires a pattern, its
FWIW, if your input has a placeholder you might deal with the issue by using
If placeholder is shown, then input hasn't been focused. However it require to use a placeholder (but as far as I tested this, it works even if placeholder is empty).