Skip to content

Commit 380ee4e

Browse files
author
Elyor Latipov
authored
Add files via upload
1 parent 603b89d commit 380ee4e

10 files changed

+4235
-0
lines changed

.gitignore/css/intlTelInput.css

+928
Large diffs are not rendered by default.

.gitignore/css/intlTelInput.min.css

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.gitignore/img/flags.png

69.2 KB
Loading

.gitignore/img/[email protected]

170 KB
Loading

.gitignore/index.html

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<title>Example: Country sync</title>
7+
<link rel="stylesheet" href="css/intlTelInput.min.css">
8+
<style>
9+
input,
10+
label {
11+
display: block;
12+
}
13+
14+
input,
15+
select,
16+
label {
17+
margin: 5px 0;
18+
}
19+
20+
.form-item {
21+
margin-bottom: 20px;
22+
}
23+
</style>
24+
</head>
25+
26+
<body>
27+
<div id="result">
28+
<div class="form-item">
29+
<label>Phone</label>
30+
<input id="phone" type="tel">
31+
</div>
32+
<div class="form-item">
33+
<label>Country</label>
34+
<select id="country"></select>
35+
</div>
36+
</div>
37+
<script src="js/intlTelInput.min.js"></script>
38+
<script>
39+
var defaultCountry = "ae";
40+
var countryItems = ["ae", "bh", "kw", "om", "qa", "sa"];
41+
var countryData = window.intlTelInputGlobals.getCountryData().filter((item) => countryItems.find(a => a == item.iso2));
42+
var phoneInput = document.querySelector("#phone");
43+
var countryDropdown = document.querySelector("#country");
44+
var iti = window.intlTelInput(phoneInput, {
45+
initialCountry: defaultCountry,
46+
separateDialCode: true,
47+
onlyCountries: countryItems,
48+
utilsScript: "js/utils.js"
49+
});
50+
51+
for (var i = 0; i < countryData.length; i++) {
52+
var country = countryData[i];
53+
var optionNode = document.createElement("option");
54+
optionNode.value = country.iso2;
55+
var textNode = document.createTextNode(country.name);
56+
optionNode.appendChild(textNode);
57+
countryDropdown.appendChild(optionNode);
58+
}
59+
countryDropdown.value = defaultCountry;
60+
61+
phoneInput.addEventListener('countrychange', function (e) {
62+
countryDropdown.value = iti.getSelectedCountryData().iso2;
63+
});
64+
65+
countryDropdown.addEventListener('change', function (e) {
66+
iti.setCountry(this.value);
67+
});
68+
69+
</script>
70+
</body>
71+
72+
</html>

.gitignore/js/intlTelInput-jquery.js

+1,377
Large diffs are not rendered by default.

.gitignore/js/intlTelInput-jquery.min.js

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.gitignore/js/intlTelInput.js

+1,348
Large diffs are not rendered by default.

.gitignore/js/intlTelInput.min.js

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.gitignore/js/utils.js

+493
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)