react-native-phone-input
react-native-phone-input copied to clipboard
Get just phone number without country code
Is there a way to separate out country code from the phone number?
@RShah512 hi , have you found a way to do this ?
Use string replace to replace the + and the first occurrence of the country code with an empty string. Auto-format must be false, or you must replace the other formatting characters and blank spaces with an empty string, as well.
const countryCode = this.phone.getCountryCode()
let phoneNumber = this.phone.getValue()
phoneNumber = phoneNumber.replace('+','')
phoneNumber = phoneNumber.replace(countryCode, '')
@yasir-netlinks Yes, I used getCountryCode function onSelectCountry property and then like @boppuh answer, I used replace to remove the '+' sign.