Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
vanilla-text-mask
Advanced tools
JavaScript function that makes input HTML element accept mask pattern
Note: IE9 is not supported in this module.
First, install it.
npm i vanilla-text-mask --save
Then, use it as follows:
<script
type="text/javascript"
src="./node_modules/vanilla-text-mask/dist/vanillaTextMask.js"></script>
<script type="text/javascript">
var phoneMask = ['(', /[1-9]/, /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/]
// Assuming you have an input element in your HTML with the class .myInput
var myInput = document.querySelector('.myInput')
var maskedInputController = vanillaTextMask.maskInput({
inputElement: myInput,
mask: phoneMask
})
// Calling `vanillaTextMask.maskInput` adds event listeners to the input element.
// If you need to remove those event listeners, you can call
maskedInputController.destroy()
</script>
As you can see in the code above, you are passing an object to vanillaTextMask.maskInput(...)
.
The object takes inputElement
, which is the <input/>
element that you are masking. It also
accepts other values which are
documented here.
To see an example of the code running, follow these steps:
git clone git@github.com:text-mask/text-mask.git
cd text-mask
npm install
npm run vanilla:dev
The code of the example is in vanilla/example
.
We would love some contributions! Check out this document to get started.
FAQs
JavaScript function that makes input HTML element accept mask pattern
The npm package vanilla-text-mask receives a total of 16,072 weekly downloads. As such, vanilla-text-mask popularity was classified as popular.
We found that vanilla-text-mask demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.