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.

Method to get only phone number without country code?

See original GitHub issue

This plugin is great, but the only thing I find that is missing is being able to easily just grab the phone number without the country code (in my case I want to store the values separately).

I know that the getSelectedCountryData method can give me the country code so I can use regex to find out the rest, but it would be a lot easier if the plugin exposed a method to do that.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:20 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
ayaseensdcommented, Jul 18, 2022

I think using JS will gives you phone number without +91

var input = document.querySelector("#phone")
    var iti = window.intlTelInput(input, {
        utilsScript: "/js/libs/tel-input-utils.js",
        customContainer: "w-100",
        initialCountry: "sa",
        onlyCountries: ['sd','sa', 'ae', 'qa', 'bh', 'om', 'kw', 'ye', 'jo', 'eg', 'ly', 'ma', 'mr'],
        preferredCountries: ['sd'],
        excludeCountries: ['il'], // except Israel 
        nationalMode: true,
        placeholderNumberType: "MOBILE",
        separateDialCode: true,
    });

var phone_number_without_plus_and_country_code = iti.getNumber().replace('+'+iti.getSelectedCountryData().dialCode,'')
1reaction
rahulthackkarcommented, May 10, 2019

Ohh yes, perfectly works fine with that.

Thanks a lot @jackocnr

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get phone contact without country code?
I'd suggest to use libphonenumber to parse the phone numbers easily. You can split the country code and phone number in this way....
Read more >
How to enter a phone number in international format - Quora
When adding international phone numbers, type the + sign, then the country code followed by the local number.
Read more >
4.3. Validate International Phone Numbers - O'Reilly
You want to validate international phone numbers. The numbers should start with a plus sign, followed by the country code and national number....
Read more >
International Calling Tip Sheet
When calling from a landline, dial 011 then the country code for Mexico, which is 52, and then the 10-digit phone number including...
Read more >
Edit phone number - Microsoft Support
When adding international phone numbers, type the + sign, then the country code followed by the local number. See the examples below, or...
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