UNPKG

phone-parser

Version:

Parse the phone input into an output format of your choice. Good for formatting a user input.

12 lines (10 loc) 297 B
<input type="text" id="phone"> <script src="index.js"></script> <script> var phoneField = document.getElementById('phone'); phoneField.addEventListener('change', function() { try{ phoneField.value = phoneParser(phoneField.value, '(xxx) xxx-xxxx'); } catch(e) {} }); </script>