Design comparison
Solution retrospective
In my time using HTML number input I've found that it's sometimes not so easy to prevent a user from entering some unwanted characters like the e, +, - and dot(.). Tried different approaches. Some of those didn't work too well. I settled on using a regex expression to replace those characters in the value. Please let me know if you've used a different method that works.
And why does the number input return an empty string for input.value when (+), (-) are the inputs. And I believe it returns only '2' when one inputs '2.'. Cos this gave me some headache when I was trying to read the value on each input and slice off the end when the character is one of the unwanted ones.
Thanks in advance
Community feedback
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord