Easy Telephone Number Input Mask JavaScript Library – phonemask

Category: Form , Javascript | July 20, 2021
Author:neovav
Views Total:6,523 views
Official Page:Go to website
Last Update:July 20, 2021
License:MIT

Preview:

Easy Telephone Number Input Mask JavaScript Library – phonemask

Description:

Just another telephone input mask JavaScript library that automatically formats telephone numbers typed in a tel input field.

How to use it:

1. Download and import the phonemask library.

<script src="../src/phonemask.min.js"></script>

2. Initialize the phonemask library.

const cssPhone = 'input[name="phone"';
(new phoneMask()).init(cssPhone);

3. Create a tel input field and determine the mask format in the mask attribute:

<input type="tel" id="phone" name="phone" value="+1 (___) ___ - ____" mask="+1 (___) ___ - ____" placeholder="+1 (___) ___ - ____" />

You Might Be Interested In:


Leave a Reply