Dilshod K
Dilshod K

Reputation: 3032

How to hide point and dash in numeric keyboardType react native

I'm new to react-native. I'm using numeric keyboard type:

<TextInput style={styles.TextInputSecond} editable = {true} maxLength={3} keyboardType="numeric" ></TextInput>

It is showing . and - also on the keyboard.

How can I hide or disable (as , disabled) them from the keyboard?

keyboard

Upvotes: 1

Views: 823

Answers (1)

Rishi Sahu
Rishi Sahu

Reputation: 516

Can you try this and check if it resolve your issue

keyboardType={Device.isAndroid ? "numeric" : "number-pad"}

or you can also Add

const onlyNumber = number.replace(/[^0-9]/g, "");

this.setState({
  onlyNumber
});

TextInput's prop value

value={this.state.onlyNumber}

Upvotes: 2

Related Questions