Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add 'Done' button on the number keypad using react-native

Tags:

react-native

i am using number-pad keyboard in react-native, i want to hide the keyboard when click on done button,for that i want to add done button above the keyboard, is there any possibility like IOS apps to hide the keyboard, Any help much appreciated

like image 587
Hussian Shaik Avatar asked Nov 20 '15 07:11

Hussian Shaik


People also ask

How do you show the next button on the keyboard react native?

returnKeyType is the right way to do this, on Android you can use returnKeyLabel , as mentioned (here)[facebook.github.io/react-native/docs/textinput#returnkeytype] If it is now showing the next button even you are using the right prop, you need to share your code sample, so that I can see for the issue.


2 Answers

I'm not sure if this is exactly what you want, but you can add a 'done' button to the keyboard using the prop returnKeyType.

E.g: returnKeyType={ 'done' }

More info here https://facebook.github.io/react-native/docs/textinput.html#returnkeytype

like image 160
Jonathan Lockley Avatar answered Oct 18 '22 10:10

Jonathan Lockley


Using React Native v.63 in 2021

  • If you just use the returnKeyType='done' it will automatically hide the keyboard
  • Notice you could also use your own function with onSubmitEditing={() => yourFunctionNameHere()}

This worked for me =>

                <TextInput
                  style={styles.textBox}
                  maxLength={5}
                  placeholder="Enter Zip Code"
                  placeholderTextColor={'#6D7376'}
                  autoCompleteType="postal-code"
                  keyboardType="number-pad"
                  returnKeyType="done"
                  onChangeText={text => setZip(text)}
                  onSubmitEditing={() => yourFunctionNameHere()}
                />

here is the direct documentation https://reactnative.dev/docs/textinput#returnkeytype

screenshot here enter image description here

like image 27
Jonathan Sanchez Avatar answered Oct 18 '22 09:10

Jonathan Sanchez