4 ms·
You want a real challenge? Build a number input that handles localizations, some countries use "," to separate decimals, and allow displaying thousand seperator
by tommica 4y ago
You want a real challenge? Build a number input that handles localizations, some countries use "," to separate decimals, and allow displaying thousand seperator automatically while typing, but read the value as a normal number during submit.
So something like "12.400,56" turns to 12400.56 and vice versa.
Also, is it just me or does this article seem to be a bit of an ad for "keenforms"? Its mentioned multiple times.
- jdthedisciple 4y agoSounds like a problem that should've been solved once and for all already. To your last point: I think it more or less obviously is an ad for keenforms, yes.
- unnouinceput 4y agoYou don't handle localization in the field directly. You let it be "text" and ask your preferred library (which is built by people smarter than you/me) to convert said text to valid number. If it converts then good, now you have a number variable in memory with which you can do whatever. If it fails you pop-up the error message and ask the user to enter a valid number. I find on the fly correction (don't let user type letters, ignore signs, etc) to be confusing to end-user.