GithubHelp home page GithubHelp logo

bn-l / input-mask Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 42 KB

An input mask with undo, paste and cut (but not redo) support. Should work everywhere.

Home Page: https://bn-l.github.io/Input-Mask/

JavaScript 44.88% HTML 55.12%

input-mask's Introduction

Input-Mask

An input mask with undo, paste and cut, and rudimentary undo/redo support. Should work everywhere.

Tested on:

  • Chrome (mac and windows 7 same behaviour): Issues with redo (works, mostly).

  • Firefox (mac and windows 7 same behaviour): Issues with undo and redo(works, mostly, but cursor pos is not good).

  • Safari (Same behaviour as Chrome)

  • iOS 10.1 safari: Undo and redo broken. Rest is fine.

  • Internet explorer 10: no undo or redo. Rest is fine.

  • Internet explorer <= 9: DOES NOT WORK

How to use:

import or require InputMask.
The imported function takes an object {} with the following keys and their settings as values:

input: Required. A DOM reference to the input you would like to apply the mask to

mask: Required. The input template / mask.

initialValue: Optional. The inital value of the input. Must have the same template as "mask"

delimiter: Required. The character used to breakup the input

chunkSize: Required. The size of the individual chunks in the template broken up by a delimiter

coerceValidDate: Optional. If the input is a date, make sure it always shows the right date

regexMatcher: Required. The regex string for allowed characters in the input.


Example usage:

import InputMask from 'some/specified/path/' (or InputMask = require('path/to/InputMask')

var inputMaskOptions = {
  input: document.getElementById('theInput'),
  mask: "  /  /    ",
  initialValue: "25/12/2011",
  delimiter: '/',
  chunkSize: [2, 2, 4],
  coerceValidDate = true,
  regexMatcher: "^[0-9]+$" // this will only match numeric characters

}

demo: https://bn-l.github.io/Input-Mask/

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.