Coder Social home page Coder Social logo

figuarnieri / maskfy Goto Github PK

View Code? Open in Web Editor NEW
14.0 3.0 2.0 37 KB

Simple, No Dependences, Mobile Compatibility, IE Compatibility Only 1kb (gzip) = ♥

Home Page: https://figuarnieri.github.io/maskfy

License: MIT License

JavaScript 23.41% HTML 76.59%
mask inputmask input-mask javascript nojquery data-mask 1kb

maskfy's Introduction

Maskfy (2.0.0) - Input Mask Simple

A Javascript library without a dependency of jQuery, Zepto, and etc ... Very simple to install and use. With only 1kb (gzip) code, IE Compatibility, it's also well accepted on mobile devices

Install / Usage

Add Maskfy file

<script src="https://cdn.rawgit.com/figuarnieri/maskfy/master/maskfy.js"></script>
or
<script src="path/js/maskfy.es5.js"></script>

HTML (by class or attribute)

Insert a selector in class tag

<input class="page--input" data-maskfy="999.999.999-99" type="text" placeholder="CPF (Ex.: 999.999.999-99)">
or
<input class="page--input mask-by-class" type="text" placeholder="CPF (Ex.: 999.999.999-99)">

Javascript Options

<script>
  new Maskfy({
    tag: '[data-maskfy]', //{String: undefined} (required) selector input
    mask: '999.999.999,99', //{String: undefined} (required) input mask pattern
    reverse: true, //{Boolean: false} reverse typing
    minSize: 3 //{Number: false} minimum digits
    defaultValue: '123' //{String: undefined} initial value
    letters: true //{Boolean: false} allowed letters
    after: (input) => console.log(input) //{Function: undefined} after input event
  });
</script>

HTML attributes [data-*]

If necessary, you could add attributes in the tag, to configure your mask options

data-maskfy

<input data-maskfy="999.999.999,99">

data-maskfy-reverse

<input data-maskfy="999.999.999,99" data-maskfy-reverse="true">

data-maskfy-minsize

<input data-maskfy="999.999.999,99" data-maskfy-reverse="true" data-maskfy-minsize="3">

data-letters

<input data-maskfy="999.999.999,99" data-maskfy-letters="true">

default value

<input data-maskfy="999.999.999,99" value="123.456.789,01">

Source

Github | npm | React | Example | @figuarnieri

License

The MIT License Copyright 2018 © Filipe Guarnieri

maskfy's People

Contributors

figuarnieri avatar joaoaugustodev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.