A Pen by Shueny Wang on CodePen.
Created
March 15, 2024 12:26
-
-
Save busraozata/85caa115e08352b57263c9b9b8448e9b to your computer and use it in GitHub Desktop.
Demo: Pure JavaScript intl-tel-input
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Demo: Pure JavaScript International Telephone Input</h1> | |
<p>Note: this demo pulls in the pure JavaScript plugin code from <a href="https://codepen.io/jackocnr/pen/ggzEjv" target="_blank">this codepen</a>.</p> | |
<form> | |
<input type="tel"> | |
<button type="submit">Validate</button> | |
</form> | |
<p id="result"></p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var input = document.querySelector("input"), | |
form = document.querySelector("form"), | |
result = document.querySelector("#result"); | |
var iti = intlTelInput(input, { | |
initialCountry: "tw" | |
}); | |
form.addEventListener("submit", function(e) { | |
e.preventDefault(); | |
var num = iti.getNumber(), | |
valid = iti.isValidNumber(); | |
result.textContent = "Number: " + num + ", valid: " + valid; | |
}, false); | |
input.addEventListener("focus", function() { | |
result.textContent = ""; | |
}, false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://codepen.io/jackocnr/pen/ggzEjv.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
margin: 20px; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/9.0.6/css/intlTelInput.css" rel="stylesheet" /> | |
<link href="http://intl-tel-input.com/node_modules/intl-tel-input/build/css/demo.css?3" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment