Format Phone Numbers With Vanilla JavaScript – phoneinput.js

Category: Form , Javascript | February 6, 2019
Author:levidavidmurray
Views Total:1,456 views
Official Page:Go to website
Last Update:February 6, 2019
License:MIT

Preview:

Format Phone Numbers With Vanilla JavaScript – phoneinput.js

Description:

phoneinput.js is a vanilla JavaScript plugin which automatically formats the phone numbers typed in an input field using your own pattern.

Basic usage:

Create a normal input field on the web page.

<input id="phoneInput" required autocomplete="off" type="text">

Download and place the JavaScript file phoneinput.js at the end of the document.

<script src="./js/phoneinput.js"></script>

Change the default pattern the entered value must match.

const defaultFormat = '({0}{1}{2}) {3}{4}{5}-{6}{7}{8}{9}';

You Might Be Interested In:


Leave a Reply