Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force TextField with type number to display dot as decimal separator

I am using material-ui to render a TextField component in my react app. It's somehow forcing all the <TextField type="number /> to have decimal separator as comma (,) instead of dot (.) which is confusing for the targeted users.

Is there any way to force it to always show dot as the decimal separator, regardless of locale?

I have created a small example here. just try to enter a number with decimals and click outside and it'll convert it into comma. This is probably because of my current device locale, but still I want to force a dot for everyone.

like image 645
noob Avatar asked Nov 05 '19 13:11

noob


1 Answers

For me, setting the language attribute to "en-US" in the inputProps worked:

<TextField
    type="number"
    inputProps={{step: "0.1", lang:"en-US"}}
 />
like image 129
goova Avatar answered Oct 22 '22 13:10

goova