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. 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]}                                      
  />
Sign up to request clarification or add additional context in comments.

3 Comments

it doesn't show 'next' key in ios when key board type is numeric or phone-pad
on ios you have to use 'done' returnKeyType: Platform.OS === 'ios' ? 'done' : 'next',
it doesn't show the dot, comma in android
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 Comments

Uh, why should placeholder affect the keyboard in any way?
I just suppose a string value could change the type of the TextInput...
2

its working for me keyboardType='numeric'

Comments

0

You need to add onChangeText for it to work

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

Comments

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"/>

Comments

-6

Maybe it will work:

keyboardType={"numeric"}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.