question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

add support for locales to format numbers in NumberInput

See original GitHub issue

Feature request

Is your feature request related to a problem? Please describe.

I’m using NumberInput and I was trying to find a way how to format the number depending on the user’s locale. I did find the pattern option but that’s only for validation on submit. It would be great to add a way to tell the NumberInput what format to use, similar to the Intl.NumberFormat class

Describe the solution you’d like

When you work with multiple locales, number format can differ. Some locales has , as the decimal separator.

I don’t know if this is planned for the future or maybe not but I think it would be a great addition to the library

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
tafelitocommented, Nov 12, 2020

but even changing the pattern to accept other formats, it will still be invalid, based on what it says on the prop comments the pattern is only used to validate on submit, right?

1reaction
tafelitocommented, Nov 12, 2020

the problem is not formatting the value or parsing it before submitting, the problem is that NI will treat the value as invalid afaik

in that same example, if you use 1,53 instead of 1.53 you’ll see that then the NI is in fact invalid and if you go up or down then you lose the value

Read more comments on GitHub >

github_iconTop Results From Across the Web

Localization of input type number - html - Stack Overflow
On my Chrome, the input type=number step=0.001 accepts 1,2 (with comma) and sends it as 1.2 and it accepts 1.200 (with a period),...
Read more >
Locale-based forms - Internationalization
Currently, it appears that the browser uses the locale of the system to determine the format of input such as numbers and dates....
Read more >
<input type="number"> - HTML: HyperText Markup Language
<input> elements of type number are used to let the user enter a number. They include built-in validation to reject non-numerical entries.
Read more >
Culture formatted custom number input
I am looking for a nice, open source, method in js/jquery to add number input fields to my page. I am located in...
Read more >
Solving Cross-Browsers Localization on Numeric Inputs
My journey to numbers-localization and cross-browser support begins. ... language by translating text and adding locale-specific components”.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found