Created
February 16, 2021 17:56
-
-
Save alexgodin/7d8328d2012bd5af3db7fd8cad6e7231 to your computer and use it in GitHub Desktop.
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
<html> | |
<body> | |
<script src="https://unpkg.com/libphonenumber-js@1.9.11/bundle/libphonenumber-min.js" crossorigin></script> | |
<!-- <script> | |
window.Retool.subscribe(function(model) { | |
if (!model) { | |
return | |
} | |
}) | |
</script> --> | |
<input type="text" inputmode="tel" id="phone-input"></input> | |
<script> | |
var input = document.getElementById('phone-input'); | |
input.onkeyup = (e) => { | |
var oldValue = input.value | |
var newValue = new libphonenumber.AsYouType('US').input(oldValue); | |
input.value = newValue | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment