2.0.6 • Published 4 years ago
int-phone-input v2.0.6
international-phone-input
A Javascript library for showing an international phone number selection input. It adds a flag dropdown to any input.
Table of Contents
Getting Started
- Download the latest release
- Include the css file
<link rel="stylesheet" href="path/to/intPhone.css">
- Add the library plugin script and initialise it on your input element
<input type="tel" id="phone">
<script src="path/to/intPhone.js"></script>
<script>
var intPhone = $("#phone").intPhone();
</script>
Methods
getPhone
Returns the complete phone number including the country code.
var phone = intPhone.getPhone();
setCountryCode
Receives a String
containing an iso2 country code and sets the specified value to the instance.
intPhone.setCountryCode("US"); // Sets all values to the ones belonging to the United States
getCountryCode
Returns the country code.
// Following the previous example the value returned is US
var countryCode = intPhone.getCountryCode();
getPhoneCode
Returns the phone code.
// Following the previous example the value returned is 1, because US phone code is +1
var phoneCode = intPhone.getPhoneCode();
getSimplePhone
Returns the phone number without the code
var phoneCode = intPhone.getSimplePhone();
setSimplePhone
Sets the phone number without the initial phone code
intPhone.setSimplePhone("3334445555");