JustPhoneMask v1.0.0
Simple and easy phone number input mask plugin
Overview
Installation
- Download the library
just-phone-mask.min.js
from the dist folder.
Alternatively, install via NPM:
npm i just-phone-mask
- Include it in your project:
<script src="just-phone-mask.min.js"></script>
Or (for module bundlers):
import JustPhoneMask from 'just-phone-mask';
new JustPhoneMask();
Methods & Properties
The library supports the following configuration options:
new JustPhoneMask( {
countryCode: '+7',
bodyMask: ' ___ ___ __ __',
setPlaceholder: false,
selectors: null,
} )
Properties
Sets the country code (default: +7
). Example:
new JustPhoneMask( {
countryCode: '+375'
} )
Defines the input mask body. The _
character acts as a placeholder. The full mask combines the country code and body mask (spaces, brackets, hyphens, etc. are allowed) (default: ___ ___ __ __
). Example:
new JustPhoneMask( {
bodyMask: ' (___) __ ___ __-__',
} )
Toggles whether to display the mask as the input’s placeholder (default: false). Example:
new JustPhoneMask( {
setPlaceholder: true,
} )
Specifies CSS selectors for target elements (uses querySelectorAll
) (default: [type="tel"]
). Example:
new JustPhoneMask( {
selectors: '.class',
} )