
This is a lightweight and easy-to-use jQuery input mask plugin to mask and validate US (or international) phone numbers in standard input fields.
See also:
How to use it:
1. Download, unzip the plugin and then insert the JavaScript jquery-input-mask-phone-number.js
after jQuery JavaScript library.
<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"> </script> <script src="jquery-input-mask-phone-number.js"></script>
2. Create a normal text field for the telephone input.
<input type="text" id="yourphone">
3. Call the function on the input field to mask and format the strings you typed in xxx-xxx-xxxx
format.
$(function(){ $('#yourphone').usPhoneFormat(); });
4. Customize the format for phone numbers.
$(function(){ $('#yourphone').usPhoneFormat({ format: '(xxx) xxx-xxxx' }); });
This awesome jQuery plugin is developed by rajaramtt. For more Advanced Usages, please check the demo page or visit the official website.
- Publication date: 03.04.2018
- Source