Socket
Socket
Sign inDemoInstall

intl-tel-input

Package Overview
Dependencies
Maintainers
1
Versions
397
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

intl-tel-input

A JavaScript plugin for entering and validating international telephone numbers


Version published
Weekly downloads
357K
increased by0.91%
Maintainers
1
Weekly downloads
Ā 
Created

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

Keywords

FAQs

Package last updated on 18 May 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with āš”ļø by Socket Inc