Posted on Leave a comment

Lightweight jQuery Input Mask Plugin For Phone Numbers | Free jQuery Plugins

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

2         integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ"
3         crossorigin="anonymous">
4 </script>
5 <script src="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 });

Lightweight jQuery Input Mask Plugin For Phone Numbers

Source: Lightweight jQuery Input Mask Plugin For Phone Numbers | Free jQuery Plugins

Leave a Reply

Your email address will not be published. Required fields are marked *