thegamenicorus / react-native-phone-input

Phone input box for React Native
https://www.npmjs.com/package/react-native-phone-input
MIT License
394 stars 447 forks source link

How to limit the input number to only 13 and user cannot enter invalid characters? #65

Open badarshahzad opened 6 years ago

badarshahzad commented 6 years ago

Hi :wave: , I appreciate your effort and struggle to develop this library. I just wanted to limit the input of phone number. I didn't know is there any way exist to do this but I make some changes in index.js on line number 196.

<View style={{ flex: 1, marginLeft: this.props.offset || 10 }}>
          <TextComponent
            ref={ref => {
              this.inputPhone = ref;
            }}
            editable={!disabled}
            autoCorrect={false}
            style={[styles.text, this.props.textStyle]}
            onChangeText={text => {
              this.onChangePhoneNumber(text);
            }}
            keyboardType="phone-pad"
            underlineColorAndroid="rgba(0,0,0,0)"
            value={formattedNumber}
            {...this.props.textProps}

            // Custom add this to limit the number input 
            maxLength={13}
          />
        </View>

So, would you like to add this feature or is this already exist then kindly enlighten me about this.

Thank you Happy Code! :+1:

luixlacrux commented 5 years ago

+1

cinder92 commented 5 years ago

+1

SirPhemmiey commented 4 years ago

Hey @badarshahzad , were you able to find a way to do this?