5 ms·
Something like conditional formatting maybe? Eg. make negative values red? Make an input field red when it contains an invalid character?
by jakobegger 9y ago
Something like conditional formatting maybe? Eg. make negative values red?
Make an input field red when it contains an invalid character?
- theandrewbailey 9y agoSounds like the pattern attribute and :invalid selector on <input> will do that. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-pattern https://developer.mozilla.org/en-US/docs/Web/HTML/Element/in...
- thefifthsetpin 9y agoWhat if it's valid? There's a reason we have the phrases "in the red" and "in the black." Another example where reading the input might be nice: input[type="cc-number"][value^="4"]+.cc-system-icon { background-image: url('visa.png'); }input[type="cc-number"][value^="5"]+.cc-system-icon { background-image: url('master-card.png'); }
- dillondoyle 9y agoI was also thinking along those lines, a way to LINT/validate form fields when JS is disabled, but seems like a very obscure and inefficient (use html5 validation + js, validate server side on submit)