📅 You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP

intl-tel-input

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
i

intl-tel-input

A JavaScript plugin for entering and validating international telephone numbers

25.3.1
latest
100

Supply Chain Security

100

Vulnerability

100

Quality

91

Maintenance

100

License

Version published
Weekly downloads
446K
2.58%
Maintainers
1
Weekly downloads
 
Created
Issues
42

What is intl-tel-input?

The intl-tel-input npm package is a JavaScript plugin for entering and validating international telephone numbers. It adds a flag dropdown to any input, which lists all the countries and their international dial codes. It also provides validation and formatting functionalities.

What are intl-tel-input's main functionalities?

Initialize the plugin

This code initializes the intl-tel-input plugin on an input field with the id 'phone'. The 'utilsScript' option is used to specify the path to the utils.js file, which is necessary for some of the plugin's advanced functionalities.

const input = document.querySelector('#phone');
const iti = window.intlTelInput(input, {
  utilsScript: 'path/to/utils.js'
});

Get the selected country data

This code retrieves the data of the currently selected country, including the country name, dial code, and ISO2 code.

const countryData = iti.getSelectedCountryData();
console.log(countryData);

Set the country

This code sets the country to the United States by passing the ISO2 code 'us'.

iti.setCountry('us');

Validate the phone number

This code checks if the entered phone number is valid according to the selected country's format.

const isValid = iti.isValidNumber();
console.log(isValid);

Get the full phone number

This code retrieves the full phone number in international format.

const fullNumber = iti.getNumber();
console.log(fullNumber);

Other packages similar to intl-tel-input

FAQs

Package last updated on 28 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts