react-nativekeyboard

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


Solution

  • 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}