Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support empty country field when the number is prefixed with + #1

Closed
fdelapena opened this issue Oct 30, 2014 · 3 comments
Closed

Support empty country field when the number is prefixed with + #1

fdelapena opened this issue Oct 30, 2014 · 3 comments

Comments

@fdelapena
Copy link

libphonenumber can guess the country if the input number starts with a plus sign (+). This is a pretty useful feature from the library and nice to have shown. Here is a hackish demonstration by sending a null character (%00 urlencoded) to the form to circunvent the required country code:

http://giggsey.com/libphonenumber/?phonenumber=%2B50689999999&country=%00

Which will resolve properly the country code by itself.

@giggsey
Copy link
Owner

giggsey commented Oct 30, 2014

How about I change the form so that it's not required, and if it's not populated, it'll use 'ZZ' (which means Unknown Region)?

@fdelapena
Copy link
Author

It is an option, however it depends about how do you want to demonstrate the library. Unfortunately parse() it does not work without country definition with numbers starting without +, e.g. 0050689999999 (just because 00 is country specific), maybe explaining this fact or simply checking via javascript if the field has a leading + to enable the unknown option in the selection dropdown, or returning an explanation after the form submit when the missing country error appears.

@giggsey giggsey closed this as completed in fe2d5dc Apr 9, 2016
@giggsey
Copy link
Owner

giggsey commented Apr 9, 2016

Quite a bit late, but I've added some help text, and made the Country Code optional (matching what parse() actually accepts).

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants