Closed jling90 closed 5 years ago
this is awesome
i never thought i would see the day.
This is awesome! Would love to see this merged!
Seems nice, please ship it 🙏
Any news?
Any news when would it be merged so as to use it??
Tired of waiting I forked this PR and adapted to my needs: automatic national phone number format:
This is a 1 hour derived library so don't expect it to cover all needs:
I got rid of google libphone version and used libphone-js one
fixed auto-format for national formats only (indentation and pattern validation)
PLEASE we need this feature :)
@thegamenicorus please Accept the PR :)
I ended up just pasting the fix into my component, make sure you do clear()
at the end though.
onCountrySelected = (country) => {
this.phoneInput.selectCountry(country.cca2.toLowerCase());
this.phoneNumberFormatter = new asYouTypeFormatter(country.cca2);
this.setState({
cca2: country.cca2
});
}
onPhoneNumberChanged = (phoneNumber) => {
let formattedNumber;
phoneNumber.replace(/-/g, '')
.replace(/ /g, '')
.split('')
.forEach(n => formatted = this.phoneNumberFormatter.inputDigit(n));
this.setState({
phoneNumber: formattedNumber
});
this.phoneNumberFormatter.clear();
}
@thegamenicorus are you alive?
@thegamenicorus THANK YOU!!!!!!
is it merged? @thegamenicorus
Adds an 'autoFormat' option to PhoneInput which allows phone numbers to be formatted as they are entered.