jackocnr / intl-tel-input

A JavaScript plugin for entering and validating international telephone numbers. React and Vue components also included.
https://intl-tel-input.com
MIT License
7.66k stars 1.95k forks source link

getNumber does not return e.164 #952

Closed twilio-jyoung closed 5 years ago

twilio-jyoung commented 5 years ago

Steps to reproduce

  1. initialize

    var input = document.querySelector("#mobile_phone_number");
    var iti = window.intlTelInput(input, {
    utilsScript: "//cdnjs.cloudflare.com/ajax/libs/intl-tel-input/16.0.2/js/utils.js",
    preferredCountries: ["us", "ca", "mx"]
    });
  2. attempt to get e.164 formatted phone number and log it

console.log(iti.getNumber()); console.log(iti.getNumber(intlTelInputUtils.numberFormat.E164));

phone number logged twice without country code, and/or any format changes

  1. be sad

Expected behaviour

phone number should be in e.164 format

Actual behaviour

phone number is in exact format as entered . ie (214) 214-2142

Initialisation options

above

jackocnr commented 5 years ago

It seems to be working on the demo page: https://intl-tel-input.com/node_modules/intl-tel-input/examples/gen/national-mode.html

Are you sure your utils.js script is loading properly? And you're only calling getNumber after that script has loaded?

jackocnr commented 5 years ago

Closing due to inactivity.