question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Validation: 11 digit Indian number validates to true

See original GitHub issue

It looks like the validation for Indian numbers continues to validate numbers with between 11-14 numbers. The following screen shot is with a valid Indian number:

screen shot 2017-09-06 at 12 54 50 pm

The following is with an 11 digit (invalid) Indian phone number, which still has isValid: true

screen shot 2017-09-06 at 12 55 21 pm

Then the following is the same situation for US numbers. First screenshot is a valid number with 10 digits with isValid: true and the second is an invalid number with 11 digits and isValid: false

screen shot 2017-09-06 at 12 56 39 pm

screen shot 2017-09-06 at 12 56 47 pm

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
catamphetaminecommented, Sep 6, 2017

Oh, man, I mislead you a bit on this one. Actually, use ‘isValidNumberCustom’ with the full metadata as described in ‘libphonenumber-js’ readme.

On Wed, 6 Sep 2017 at 21:44, Graham Lutz notifications@github.com wrote:

So I’ve got that in place, and it’s pulling it in but does’t change anything. This is what the props on our phone component looks like:

[image: screen shot 2017-09-06 at 2 42 09 pm] https://user-images.githubusercontent.com/12991947/30128748-c6b7fd82-9311-11e7-96c5-db073d214c2c.png

And this is what I am using to validate:

handleBlur = (e) => { let phone = e.target.value;

if (!isValidPhoneNumber(phone) && phone != "") {
  this.setState({isValid: false});
}
else {
  this.setState({isValid: true});
}

};

Any other thoughts?

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/catamphetamine/react-phone-number-input/issues/70#issuecomment-327577523, or mute the thread https://github.com/notifications/unsubscribe-auth/AAdH7yTnoBEFBp65ad0bj6P6YV1keyQAks5sfugYgaJpZM4POruA .

0reactions
grahamlutzcommented, Sep 6, 2017

So I’ve got that in place, and it’s pulling it in but does’t change anything. This is what the props on our phone component looks like:

screen shot 2017-09-06 at 2 42 09 pm

And this is what I am using to validate:

handleBlur = (e) => {
    let phone = e.target.value;

    if (!isValidPhoneNumber(phone) && phone != "") {
      this.setState({isValid: false});
    }
    else {
      this.setState({isValid: true});
    }
};

Any other thoughts?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to validate Indian Passport number using Regular ...
Output: true. Explanation: The given string satisfies all the above mentioned conditions. Therefore it is a valid passport number of India.
Read more >
Regular Expression Validation For Indian Phone Number ...
Regular Expression to validate 11 or 12 (starting with 0 or 91) digit number ... All mobile numbers in India start with 9,...
Read more >
JavaScript: HTML Form - Phone Number validation
At first, we validate a phone number of 10 digits with no comma, no spaces, no punctuation and there will be no +...
Read more >
Simple Way to Validate Phone Numbers in PHP
An easy walkthrough of how to validate phone numbers in PHP. ... Let's say that the genuine phone number is 10 digits long,...
Read more >
[Solved] How to check only 10 digit mobile number regex
So ... the data you are checking is not what you think it is. Use the debugger to check exactly what is in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found