12

Here is my instance

var LoginPopup=React.createClass({
   render:function(){
            return(
               <View>
                   <TextInput placeholder="number" keyboardType="numeric"/>
 <TextInput placeholder="url" keyboardType="url"/>

               </View>
            )

  }
})

In this component any type of keyboardType is not working(like number,url, email-address,number-pad,phone-pad etc ,)

3
  • What do you mean by not working? Is the component not visible? Or the keyboard is not numeric? Commented Aug 25, 2015 at 11:06
  • 1
    I am facing same problem in android. @Chirag - I think 'vasavi' is referring to a problem that - keyboardType="numeric" opens up the keyboard which has characters too. Ideally it should open a keyboard with numbers only. We have such keyboard in android.
    – C.P.
    Commented Dec 26, 2015 at 6:41
  • @C.P. No, Android doesn't have a keyboard like that. Android doesn't have a keyboard at all. The keyboard is a separate app that's different for each model of phone (or can be replaced by the user), and depending on the model of phone it may or may not have a numeric only screen. There's no requirement for it. Nor is there a requirement that a given keyboard app honor the inputType being set to numeric. Commented Sep 4, 2023 at 2:03

6 Answers 6

9
<TextInput value={this.state.mobileNumber}
     returnKeyType={'next'}
     keyboardType={'phone-pad'}
     onChangeText={(mobileNumber) => this.setState({mobileNumber})}
                                       style={[styles.input]}                                      
  />
3
  • 1
    it doesn't show 'next' key in ios when key board type is numeric or phone-pad Commented Jun 28, 2019 at 12:01
  • 2
    on ios you have to use 'done' returnKeyType: Platform.OS === 'ios' ? 'done' : 'next',
    – Charly
    Commented Sep 14, 2019 at 15:45
  • it doesn't show the dot, comma in android Commented Aug 4, 2021 at 23:08
4

keyboardType="numeric" does work for me on react-native 0.46.3 on both Android and iOS.
Are you sure using an alphabetical placeholder ("number") is not the cause of the issue?

This is my relevant code:

<TextInput
    editable={!this.state.user.logged}
    onChangeText={(mobileNumber) => this.setState({mobileNumber})}
    placeholder={I18n.t('MobileNumber')}
    ref='mobileNumber'
    returnKeyType={(Platform.OS === 'ios') ? 'done' : 'next'}
    placeholder={I18n.t('MobileNumber')}
    style={styles.inputText}
    underlineColorAndroid='rgba(0,0,0,0)'
    value={this.state.mobileNumber}
    keyboardType="numeric"
/>
2
  • Uh, why should placeholder affect the keyboard in any way?
    – Sulthan
    Commented Jan 9, 2018 at 19:09
  • I just suppose a string value could change the type of the TextInput...
    – MarcoS
    Commented Jan 9, 2018 at 19:10
2

its working for me keyboardType='numeric'

0

You need to add onChangeText for it to work

<TextInput placeholder="number" keyboardType="numeric" onChangeText={() => { }} /> 
0

You need to add the prop inputMode="numeric" and inputMode="url" as follows:

<TextInput placeholder="number" keyboardType="numeric" inputMode="numeric"/>
<TextInput placeholder="url" keyboardType="url" inputMode="url"/>
-6

Maybe it will work:

keyboardType={"numeric"}

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.