1.8.3 • Published 8 years ago

maskerjs v1.8.3

Weekly downloads
16
License
MIT
Repository
github
Last release
8 years ago

MaskerJS

GitHub release npm version npm downloads npm downloads

A simple JavaScript library for masking HTML input fields.

Install:

$ npm install --save maskerjs

What MaskerJS Looks Like

maskerjs gif

app.html:

<input id="tel" type="tel" placeholder="+1-234-567-8900">

app.js:

var Masker = require('maskerjs');

var telMask = new Masker(
    [
        '___-____',            // local
        '(___) ___-____',      // area
        '+_-___-___-____',     // international
    ],
    /^[0-9]$/ // allowed chars
);

var telInput = document.getElementById('tel');

telMask.mask(telInput);
// telMask.unmask(telInput);

var val = telMask.unmaskVal(telInput.value);

Use MaskerJS with jQuery

var Masker = require('maskerjs');

// added the plugin to jQuery
Masker.jQueryPlugin(jQuery);

var telMask = new Masker(
    [
        '___-____',            // local
        '(___) ___-____',      // area
        '+_-___-___-____',     // international
    ],
    /^[0-9]$/ // allowed chars
);

// pass in a Masker object
jQuery('input[type="tel"]').mask(telMask);

// pass in the constructor arguments
jQuery('input[type="tel"]').mask(
    [
        '___-____',            // local
        '(___) ___-____',      // area
        '+_-___-___-____',     // international
    ],
    /^[0-9]$/ // allowed chars
);

// remove the masker
jQuery('input[type="tel"]').unmask();

// get the element.value masked with the passed in masker
jQuery('input[type="tel"]').maskVal(masker);
jQuery('input[type="tel"]').maskVal(patterns, filter);

// get the element.value unmasked
jQuery('input[type="tel"]').unmaskVal();
1.8.3

8 years ago

1.8.2

8 years ago

1.8.1

8 years ago

1.8.0

8 years ago

1.7.0

8 years ago

1.6.0

8 years ago

1.5.0

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.13

8 years ago

1.0.12

8 years ago

1.0.11

8 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.0.0

8 years ago