International Telephone Input

It is a jQuery plugin for entering and validating international telephone numbers. It adds a flag dropdown to any input, detects the user’s country, displays a relevant placeholder and provides formatting/validation methods.

It is also widely known as intl-tel-input.

Below is some of its advanced features:

  • Provides a very friendly user interface to enter a phone number. All countries are shown as a drop list with the flags and suggestion phone number
  • Provides up-to-date patterns of phone numbers in the world. The data are taken from Google libphonenumber library so they are completely stable.
  • Has a few APIs to validate and integrate with other tools

How to use:

1) Download the latest release for intl-tel-input. You can download it from .

2) Include the stylesheet:

<link rel=”stylesheet” href=”path_to_intlTelInput.css”>

3) Override the path to flags.png in your CSS :

.iti-flag {background-image: url(“path_to_flags.png”);}

4) Add the plugin script and initialise it on your input element:

<script src="path_to_jquery-2.2.0.min.js"></script>
<script src="path_to_intlTelInput.js"></script>
<script> $("#phone").intlTelInput();</script>


Full width input
If you want your input to be full-width, you need to set the container to be the same i.e.

.intl-tel-input {width: 100%}

A sample working example using intl-tel input: (phoneDemo.html)

<link rel="stylesheet" href="intl-tel-input-9.0.0 (2)/build/css/intlTelInput.css">
   .iti-flag {background-image: url("/home/knodus/Downloads/intl-tel-input-9.0.0 (2)/build/img/flags.png");}
<body>phone number
<input type="tel" id="phone">
   <script src="jquery-2.2.0.min.js"></script>
   <script src="intl-tel-input-9.0.0 (2)/build/js/intlTelInput.js"></script>

Some Useful Options:

1) autoPlaceholder

Default: true
Set the input’s placeholder to an example number for the selected country. If there is already a placeholder attribute set on the input then that will take precedence. Requires the utilScript option.

For Example:

    var telInput = $(“#phone);
       utilsScript: “path_to_utils.js”, //file from google’s libphonenumber library

2) utilsScript


Example : “build/js/utils.js”
Enable formatting/validation etc. by specifying the path to the included utils.js script ,which is fetched only when the page has finished loading (on window.load) to prevent blocking.

3) isValidNumber
It Validate the current number present in the textbox. Expects an internationally formatted number unless ‘national mode’ is enabled. If validation fails, you can use getValidationError to know about the error occured. Requires the utilScript option.

Var isValid = $(“#phone”).intlTelInput(“isValidNumber”);

Returns: true/false

Utilities Script

It uses a custom build of Google’s libphonenumber which enables the following features:

  • Formatting upon initialisation
  • Validation with isValidNumber, getNumberType and getValidationError methods

Specifying utilsScript in Code:

    var telInput = $(“#phone);
    utilsScript: “path_to_utils.js”

NOTE: util.js file is from google’s libphonenumber library.

Applying Validations on the phone number field

Given below is a demo example for applying validation on the intl-tel-input field:

<link rel="stylesheet" href="intl-tel-input-9.0.0 (2)/build/css/intlTelInput.css">
.iti-flag {background-image: url("intl-tel-input-9.0.0 (2)/build/img/flags.png");}
<form id="userPhoneForm" role="form" method="post" >
phone number
<input type="tel" id="phone" name="phone">
<span class="input-group-btn" style="color:red;">
<button class="addPhoneSubmit" type="submit" onclick="validate()">Add Phone Number </button>
<div id ="userPhoneDiv" ></div>
<script src="jquery-2.2.0.min.js"></script>
<script src="jquery.validate.min.js"></script>
<script src="intl-tel-input-9.0.0 (2)/build/js/intlTelInput.js"></script>
<script src="libphonenumber/utils.js"></script>
<script type="text/javascript">
$.validator.addMethod("phoneNumValidation", function(value) {
    return $("#phone").intlTelInput("isValidNumber")
}, 'Please enter a valid number');
var validate = function() {
rules: {
phone: {
required: true,
phoneNumValidation: true
messages: {
phone: {
required: "Phone number is required field."
errorPlacement : function(error, element) {
$(document).ready(function() {
   console.log("in ready");
   $("#phone").intlTelInput({utilsScript: "libphonenumber/utils.js"});


If someone still face any problem while using intl-tel input, you can get the above working example from the github repo: , including all the required files.




This entry was posted in Scala and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s