Giter VIP home page Giter VIP logo

Comments (5)

jackocnr avatar jackocnr commented on May 25, 2024

Can I ask why you want this?

Did you know that even if the user types their number in the national format (without the international dial code), you can always use getNumber to get the full international number (including the international dial code)?

from intl-tel-input.

Magic73 avatar Magic73 commented on May 25, 2024

HI,
to add validation on the obligatory nature of having a prefix without having to use other tools afterwards, such as pop-ups or external alerts. Some of our users, when editing the telephone number, have the habit of removing the prefix with the result that the subsequent sending of a text message fails due to the lack of it.

By having an integrated validation check that requires the presence of the prefix, we standardize the input error reporting.

from intl-tel-input.

jackocnr avatar jackocnr commented on May 25, 2024

As per my previous message, you do not need to restrict the user in this way. You can allow the user to enter their number however they like, and you can always get the standardised international number using getNumber. Closing for now, but let me know if you have any problems.

from intl-tel-input.

Magic73 avatar Magic73 commented on May 25, 2024

image

calling getNumber on this, doesn't return +41 12345678

image

Edit ----------

I just solved in this way:

  input.onblur = function () {
      if (input.value) {
          const countryData = iti.getSelectedCountryData();
          iti.setCountry(countryData.iso2);
          const number = iti.getNumber();

          input.value = number;
          iti.setNumber(number);

          var event = new Event('change');
          input.dispatchEvent(event); // Notify Blazor about the change
      }
  }

from intl-tel-input.

jackocnr avatar jackocnr commented on May 25, 2024

calling getNumber on this, doesn't return +41 12345678

No because that's not a valid number. As per the readme, getNumber only works with valid numbers so you need to use isValidNumber to confirm the number is valid first. If it is valid, then you can use getNumber to get the full international number.

from intl-tel-input.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.