今日已更新 246 条资讯 | 累计 21112 条内容
关于我们

How would you build OTP component?

/u/truenapalm 2026年06月04日 00:39 5 次阅读 来源:Reddit r/webdev

Hey all, some time ago I had an interview for a Frontend Engineer role at Stripe and had this question for my coding round: Develop OTP component that has 4 inputs: - accepts only digits - when one input is populated => auto-focus to the next - submit on enter - should support backspace - should be accessible I was using React and was trying to make it via 4 separate <input> elements heavily relying on the built-in HTML validation attributes (to save time, interviewer agreed it was ok). I made it work with auto-focus and everything but still got rejected. Now I'm curious how other would approach such challenge. I will attach an image in the comments for a visual reference. submitted by /u/truenapalm [link] [留言]

本文内容来源于互联网,版权归原作者所有
查看原文