-
Notifications
You must be signed in to change notification settings - Fork 464
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
Get regex to use elsewhere #394
Comments
I would recommend grabbing a JavaScript version of libphonenumber in order to do frontend validation. |
That’s how you get inconsistencies... |
There are multiple JS ports of libphonenumber, and like this PHP port, they
release as close to Google as possible.
There are functions within the library to get the regex, although I'm not
sure they are public. But then you need to decide which ones to use. Each
region will have a general regex, then more detailed ones for the different
number formats.
You'd then need to deal with the user typing the number in different
formats. For example, I may type a UK number as 0117 496 0123 or
+441174960123 or even just 1174960123. All three of read by the library as
the correct number.
…On Wed, 29 Jul 2020, 18:31 James Wade, ***@***.***> wrote:
That’s how you get inconsistencies...
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#394 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACKUQWGGXCFS3NQJV4T5RLR6BMFPANCNFSM4PLXEJEQ>
.
|
I'm really only interested in one region for general purposes, which is why pulling in large javascript packages of hundreds of megabytes seems a bit overkill, while, if it could be pulled from this library, in theory, it should evaluate to a few bytes. Google's libphonenumber supports javascript out of the box and is 1.2kb when minified and gzipped so this might just do the trick. |
It'd be really nice if there was some kind of interface that you could use to get the phone number regex so you could use that within HTML5 regex so the two could be consistent.
See: http://html5pattern.com/Phones
The text was updated successfully, but these errors were encountered: