Is there a way to key a numeric keypad without punctuations?
<TextInput keyboardType='numeric' ..... />
if I use secureTextEntry={true}
, it gets the right keyboard I want, but the values are replaced with *
.
so, this is what im getting:
This is what I want:
The <Display> is the number pad's equivalent of React Native's <TextInput> component. It is a controlled component that, when pressed, opens the number pad.
The numpad's keys are digits 0 to 9 , + (addition), - (subtraction), * (multiplication) and / (division) symbols, . (decimal point), Num Lock , and ↵ Enter keys.
I had the same problem.
I could solve doing something like this:
keyboardType={Device.isAndroid ? "numeric" : "number-pad"}
and then in a method call from onChangeText
doing this:
const cleanNumber = number.replace(/[^0-9]/g, "");
this.setState({
cleanNumber
});
and it the value prop of TextInput
value={this.state.cleanNumber}
keyboardType={"number-pad"} Works on Android. Note: I am using FormInput from react-native-elements.
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