Git Product home page Git Product logo

intl-tel-input's Introduction

International Telephone Input

A jQuery plugin for entering international telephone numbers. It adds a flag dropdown to any input, which lists all the countries and their international dial codes next to their flags.

Demo

http://jackocnr.com/intl-tel-input.html
Try it for yourself using the included demo.html

Getting started

First add the stylesheet to your <head>

  <link rel="stylesheet" href="build/css/intlTelInput.css">

Then include the plugin and initialise it on your input element

  <input type="tel" id="mobile-number">

  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  <script src="build/js/intlTelInput.min.js"></script>
  <script>
    $("#mobile-number").intlTelInput();
  </script>

Current features

  • In the country dropdown you can navigate by typing, or using the up/down keys

  • Selecting a country updates the dial code of the entered number

  • Typing a different dial code automatically updates the displayed flag

  • Option to insert the default country's dial code upon initialisation (enabled by default)

      initialDialCode: false
    
  • Option to specify "preferred countries" (which appear at the top of the list) e.g.

      preferredCountries: ["US", "GB"]
    
  • Option to set "america mode" (disabled by default), which doesn't display the +1 for American numbers, because a lot of Americans are unfamiliar with international dial codes

      americaMode: true
    
  • Programatically select a country after initialisation (e.g. when the user is entering their address)

      $('#mobile-number').intlTelInput('selectCountry', 'GB');
    

Roadmap

If there's enough interest, I may look into adding the following features:

  • Number validation
  • Option to use your own country data

Troubleshooting

  • Depending on your project setup, you may need to override the path to flags16.png in your CSS. You can do so like this:

      .f16 .flag {background-image: url("path/to/flags16.png");}
    

Attributions

intl-tel-input's People

Contributors

jackocnr avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

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.