Some iOS devices seems to be showing a ,
(comma) instead of a .
on the decimal-pad. I believe this is to do with the keyboard language / locale. Is there a way I can force the decimal-pad
to show a .
regardless of keyboard language / locale?
<TextInput
rejectResponderTermination={false}
style={[
{
fontSize: entryValueFontSize,
height: height,
},
calculatorStyles.inputsShared,
calculatorStyles.amountInput,
theme.inputsShared,
]}
autoCapitalize={'none'}
placeholder={entryValueLabel}
placeholderTextColor={theme.placeholderTextColor}
keyboardType={'decimal-pad'}
returnKeyType={'done'}
defaultValue={''}
value={isNaN(this.state.entryValue) ? '' : this.state.entryValue}
onChangeText={(entryValue) => {
this.onEntryValueChange(entryValue);
}}
/>
Problem:
Desired output:
It is not possible to force keyboard to use comma. It is based on Region for example Czechia has comma. The solution I have created is to replace comma for decimal with point once comma is entered
<TextInput
onChangeText={(entryValue) => {
// I am passing keyboardType as prop
if (keyboardType === 'decimal-pad') {
this.onEntryValueChange(entryValue.replace(',', '.'));
} else {
this.onEntryValueChange(entryValue);
}
}}
/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With