automask

0.4.0 • Public • Published

AutoMask

Auto mask your inputs without setting JavaScript

module version  GitHub license  contributions welcome

Instable version

    This version is below version 1.0.0 and some unexpected behaviors may occur.

Install

npm i automask

or just import the javascript into /dist/web/ into your web project.

Import

Module

Just import with require and use:

require('automask')

Web

Download script into /dist/web/ folder and import normally:

<script type="text/javascript" src="automask.min.js"/>

Usage

All settings are usable on HTML and works on IE11+ browsers.

<!-- MAC Address -->
<input mask="__:__:__:__:__:__" accept="0-9A-Fa-f" />
 
<!-- show the empty mask -->
<input mask="__:__:__:__:__:__" accept="0-9A-Fa-f" show-mask="true" />
 
<!-- Percentage -->
<input mask="__0,0" dir="backward" suffix="%" />
 
<!-- Money -->
<input mask="___.__0,00" dir="backward" prefix="" persist="\d," />

Settings

All AutoMask settings are enabled with HTML. Just set the attribute and use.

  • mask to define your pattern;
  • prefix to set an prefix;
  • suffix to set an suffix;
  • show-mask to set whether or not to display the mask;
  • accept Regular Expression for accepted characters (default is only numbers);
  • persist Regular Expression to set what characters submit on form.
  • [BETA] dir to set fill direction;

Mask

The mask accepts all characters and have only two special characters, the _ and 0. These characters are where your value will stay, and the 0 will works like an zero pad (for example, to pad the money or percentage).

Dir

The dir set the completion direction. Accept two values, backward and forward. The default value is forward.

Author

License

MIT License

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i automask

    Weekly Downloads

    1

    Version

    0.4.0

    License

    MIT

    Unpacked Size

    17.6 kB

    Total Files

    5

    Last publish

    Collaborators

    • ecromaneli