GithubHelp home page GithubHelp logo

Comments (1)

catamphetamine avatar catamphetamine commented on July 3, 2024

Hmm, yeah, this behaviour seems like a bug which isn't really a bug.
Google's libphonenumber was originally created to match phone numbers in a non-strict matter meaning that it would rather attempt to parse a strictly speaking invalid phone number than just dismiss it (it's like web browsers render HTML – they prefer to render at least something as long as they can do that).
So, Google's library behaviour is the same:
https://libphonenumber.appspot.com/phonenumberparser?number=%2B330612345678&country=US
Analogous, it doesn't format the phone number in as you type formatter and it also considers this kind of a phone number valid.
I could introduce some kind of a { strict: true } option which would be passed to parse(number, options) and parse() could return nothing if the number is international and contains a national prefix.
Still, from a website owner's perspective it's better to not loose clients just because they don't know how to write their phone numbers right.

If your website is for France only then you should use local phone number format.
It will suit grandma.
But the younger generation may not know how to input a local phone number, they will want to do that in international format.
Therefore, I think, the best way is to accept both local and international phone numbers: if the first sign in + then switch to international parsing mode; if not – switch to local parsing mode.
This is the behaviour of react-phone-number-input
http://halt-hammerzeit.github.io/react-phone-number-input/

So, in summary, this behaviour is exactly what Google's library does, and I could introduce a special { strict: true } flag for parsing but almost anyone would prefer to forgive such input errors not to loose customers.
If you highlight such a phone number as "wrong" the customer may not know what's wrong and may just navigate away from the website (not placing the order).
The formatting is not critical in this case because it doesn't limit functionality.
I guess this sums it up.

from libphonenumber-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.