4 ms·
This may not be semantically pure, but I think type="tel" is a simple and ergonomic approach to credit card input. https://developer.mozilla.org/en-US/docs/Web/
by brlewis 7y ago
This may not be semantically pure, but I think type="tel" is a simple and ergonomic approach to credit card input. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/tel https://developer.mozilla.org/en-US/docs/Web/HTML/Element/in...
EDIT: Also more widely supported than https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode#Browser_compatibility https://developer.mozilla.org/en-US/docs/Web/HTML/Global_att...
- Wowfunhappy 7y agoI'm not against weird hacks where necessary, but how is this better than the GP's non-hacky suggestion? Inputmode isn't supported by most desktop browsers but it doesn't need to be. Every mobile browser save mobile Firefox supports it. ...I wonder what's up with Mobile Firefox?
- brlewis 7y agoUsing the same markup for desktop and mobile means less code which usually translates to fewer bugs.
- Wowfunhappy 7y agoIt would be the same markup. It just wouldn't do anything on desktop. Which is fine because desktops generally have physical keyboards. I apologize if you already know this, but to make sure we're on the same page: what "inputmode" does is tell phones to display the onscreen keyboard as a numpad, instead of a full set of QWERTY letters and numbers. Outside of a few edge-cases, you don't generally need that on desktop.
- brlewis 7y agoTBH I went on autopilot looking at MDN's browser compatibility list. Also as a user of Firefox on Android I was interested in something that works there, but type="tel" doesn't behave any better. The only advantage to not using inputmode is getting rid of an HTML validator warning, so you're right.