just-phone-mask
v1.0.1
Published
Simple and easy phone number input mask plugin
Maintainers
Readme
JustPhoneMask v1.0.0
Simple and easy phone number input mask plugin
Overview
No dependencies. Written in pure JavaScript — no additional libraries required.
Simplicity and functionality. Easily integrate and use the plugin to enforce phone number masking.
Installation
- Download the library
just-phone-mask.min.jsfrom 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';- Initialize the library:
new JustPhoneMask();Methods & Properties
The library supports the following configuration options:
new JustPhoneMask( {
countryCode: '+7',
bodyMask: ' ___ ___ __ __',
setPlaceholder: false,
selectors: null,
} )Properties
countryCode
Sets the country code (default: +7). Example:
new JustPhoneMask( {
countryCode: '+375'
} )bodyMask
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: ' (___) __ ___ __-__',
} )setPlaceholder
Toggles whether to display the mask as the input’s placeholder (default: false). Example:
new JustPhoneMask( {
setPlaceholder: true,
} )selectors
Specifies CSS selectors for target elements (uses querySelectorAll) (default: [type="tel"]). Example:
new JustPhoneMask( {
selectors: '.class',
} )