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

PhoneUS Method isn't accurate #2126

Open
itstabish opened this issue Jan 14, 2018 · 6 comments
Open

PhoneUS Method isn't accurate #2126

itstabish opened this issue Jan 14, 2018 · 6 comments

Comments

@itstabish
Copy link

Subject of the issue

PhoneUS Method is supposed to validate phone numbers to ensure they follow the 9 digit protocol. Phone numbers cannot be all 1's or a series of consecutive numbers such as 1234567. This is enough of a deterrent. However, yesterday, I came across a form, that when filled with the value 555 555 5555, validated as correct. Of course, this form IS incorrect.

Your environment

1.16.0
Chrome 63.0.3239.132

Steps to reproduce

Visit https://jsfiddle.net/ssguf2jy/
Fill in the phone number as 555 555 5555

Expected behaviour

An error should appear to the right of the field saying "x Please specify a valid phone number"

Actual behaviour

A check mark appears to the right of the field that denotes valid data.

@Arkni
Copy link
Member

Arkni commented Mar 17, 2018

Hi @itstabish,

Thanks a lot for filing this issue! Would you like to write a patch for this? I'd be more than happy to walk you through the steps involved.

@itstabish
Copy link
Author

itstabish commented Mar 18, 2018 via email

@Arkni
Copy link
Member

Arkni commented Mar 18, 2018

No worries.

I don't know much about US phone numbers and how they should be validated, so I will let this issue for anyone experienced in validating these phone numbers and interested in fixing it.

Thanks!

@RobJohnston
Copy link
Contributor

Let me take a moment to argue that 555-555-5555 is a valid number.

According to the Wikipedia page on the North American Number Plan (NANP), a phone number is in the form NPA-NXX-xxxx.

The NPA, or numbering plan area code, can start with digits 2-9 and have 0-9 as the second and third digit, so the first 555 is valid.

The NXX, or central office exchange code, has the same rule but the third digit cannot be 1 if the second digit is 1, so the second 555 is valid.

And finally, there's this quote:

Despite the widespread usage of NXX 555 for fictional telephone numbers..., the only such numbers now specifically reserved for fictional use are 555-0100 through 555-0199, with the remaining 555 numbers released for actual assignment as information numbers.

So, all that being said, the number 555-555-5555 is valid.

But, I would argue that for the next version of JQuery Validation, that the phoneUS method be renamed to phoneNANP because it covers 20 countries. Then we could use the List of North American Numbering Plan area codes to create country-specific methods.

I concede that on that page of area codes that the NPA 555 is "Reserved for directory assistance applications, not used". But a lot of other aren't used either.

@Arkni
Copy link
Member

Arkni commented Mar 18, 2018

@RobJohnston

Thanks a lot for the detailed answer. We really appreciate it.

But, I would argue that for the next version of JQuery Validation, that the phoneUS method be renamed to phoneNANP because it covers 20 countries.

I'm +1 for changing the name of the method in the next major version.

Then we could use the List of North American Numbering Plan area codes to create country-specific methods.

Can't we configure the method to validate only a specific range of area codes? like it is done for creditcardtype method. We can make it validate all area codes by default, but can be overrided to only validate sepecific areas. Wdyt?

@RobJohnston
Copy link
Contributor

Yes, exactly what I was thinking.

@github-actions github-actions bot added the stale Used to mark stale issues label Jun 15, 2023
@jquery-validation jquery-validation deleted a comment from github-actions bot Jun 15, 2023
@bytestream bytestream added Status: Verified and removed stale Used to mark stale issues labels Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants