2 ms·
HTML5’s built-in validation is actually not all it’s cracked up to be just yet, because the currently defined and supported CSS selectors don’t cover all cases
by chrismorgan 8y ago
HTML5’s built-in validation is actually not all it’s cracked up to be just yet, because the currently defined and supported CSS selectors don’t cover all cases needed: you don’t want all your fields to be styled invalid on page load, only once the user has interacted with them or tried to submit. Firefox has :-moz-ui-invalid, I don’t think others have anything, and :user-invalid is the direction Selectors Level 4 is going, see https://drafts.csswg.org/selectors-4/#user-pseudos https://drafts.csswg.org/selectors-4/#user-pseudos.
If you want a pleasant experience, you can’t use HTML form validation by itself. You need some added JavaScript.
(I am not defending over a megabyte of JavaScript. I like to do such things from scratch and optimise for size, and all the functionality that I see on that page looks like it’d comfortably fit in under ten kilobytes of JavaScript. The CSS can probably also be decimated. But these things only happen that way if you value such performance, and few do—perhaps justifiably, perhaps not.)