Back

# Example: National Mode

Allow users to enter their national number, and then convert it to international format using the public method getNumber.

## Markup

    <p id="output">Please enter a valid number below</p>
    <input id="phone" type="tel">

## Code

    var input = document.querySelector("#phone"),
      output = document.querySelector("#output");

    var iti = window.intlTelInput(input, {
      nationalMode: true,
      utilsScript: "../../build/js/utils.js?1638200991544" // just for formatting/placeholders etc
    });

    var handleChange = function() {
      var text = (iti.isValidNumber()) ? "International: " + iti.getNumber() : "Please enter a number below";
      var textNode = document.createTextNode(text);
      output.innerHTML = "";
      output.appendChild(textNode);
    };

    // listen to "keyup", but also "change" to update when the user selects a country
    input.addEventListener('change', handleChange);
    input.addEventListener('keyup', handleChange);

## Result

Please enter a valid number below