jQuery Input Mask Phone Numbers - Free Download Lightweight jQuery Input Mask Plugin For Phone Numbers

Free Download Lightweight jQuery Input Mask Plugin For Phone Numbers

Posted on

This time I will share jQuery Plugin and tutorial about Lightweight jQuery Input Mask Plugin For Phone Numbers, hope it will help you in programming stack.

jQuery Input Mask Phone Numbers - Free Download Lightweight jQuery Input Mask Plugin For Phone Numbers
File Size: 5.95 KB
Views Total: 30414
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

This is a lightweight (less than 2kb) and easy-to-use jQuery input mask plugin to mask and validate US (or international) phone numbers in standard input fields.

How to use it:

1. Download, unzip the plugin and then insert the JavaScript jquery-input-mask-phone-number.js after jQuery JavaScript library.

1 <script src="/path/to/cdn/jquery.min.js"></script>
2 <script src="/path/to/jquery-input-mask-phone-number.js"></script>

2. Create a normal text field for the telephone input.

1 <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.

1 $(function(){
2  
3   $('#yourphone').usPhoneFormat();
4  
5 });

4. Customize the format for phone numbers.

1 $(function(){
2  
3   $('#yourphone').usPhoneFormat({
4     format: '(xxx) xxx-xxxx'
5   });
6  
7 });

Changelog:

2020-11-02

  • Add support for macOS Command key

2020-08-22

  • Fixed Tab issue

2020-08-10

  • Bugs fixed

2020-05-13

  • Added touchend

2019-04-09

  • Phone mask updated

2018-10-30

  • Fixed Mozilla Firefox backspace issue