Giter Site home page Giter Site logo

text-mask / text-mask Goto Github PK

View Code? Open in Web Editor NEW
8.3K 8.3K 829.0 5.31 MB

Input mask for React, Angular, Ember, Vue, & plain JavaScript

Home Page: https://text-mask.github.io/text-mask/

License: The Unlicense

JavaScript 91.61% HTML 3.85% CSS 0.15% Shell 0.97% TypeScript 2.50% Vue 0.40% Handlebars 0.20% SCSS 0.33%
angular ember input-mask inputmask react text-formatting vue

text-mask's Introduction

Text Mask

โš ๏ธ This library is not maintained. Pull-requests and issues are not monitored. Below are some alternatives to text-mask (Please note that the alternatives below are not checked or verified by the maintainers of Text Mask):

If you know other alternatives that should be listed here, email me at [email protected].


Build Status

Text Mask is an input mask library. It can create input masks for phone, date, currency, zip code, percentage, email, and literally anything!

There are convenient wrappers for React, Angular 2, Ember, and Vue.

Live demo

See it in action, check out the demo page.

Installation and usage

Expected to work with...

IE9+, Android, Samsung Internet, Windows Phone, iOS, Opera, Firefox, Safari, and Chrome

Flexible

Text Mask is very configurable and allows you to create any type of input mask with minimal APIs. See the documentation for details.

Extendable

You can easily expand the base functionality of Text Mask with addons for more mask types. Checkout existing addons.

Robust

Text Mask supports pasting, browser auto-fill, and all operations that a user would expect while interacting with an input field.

It works on mobile, has no 3rd party dependencies, and has a tiny footprint (less than 4KB gzipped).

For any questions, suggestions, or feature requests

Please file an issue!

text-mask's People

Contributors

akiran avatar andyrue avatar antialias avatar billcolumbia avatar browniefed avatar c01nd01r avatar dtupalov avatar erikshestopal avatar farleyta avatar freewil avatar friartuck6000 avatar greenkeeperio-bot avatar ihadeed avatar kevgathuku avatar loki29pl avatar lozjackson avatar marcioj avatar marcocarosi avatar mathieu-neron avatar maxisam avatar mihnsen avatar msafi avatar mzedeler avatar nabausch avatar perfectpixel avatar semirturgay avatar sky-coding avatar snewcomer avatar svenergy avatar tiagofscoelho avatar

Stargazers

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

Watchers

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

text-mask's Issues

change guide

How can i change the guide to flase in angular2?

unable to use 2 way data binding

hi,

i know 2 way data binding is not a great idea but still your plugin does not work with it - angulars change detections is always one action behind real value.

ill provide a plunker in few hours

Can't find module in angular 2

I run "npm i angular2-text-mask --save" and call the module, but the angular can't find him. I looked the code and the core paste isn't in the "node_modules/angular2-text-mask". Did you already see this?

Error: No provider for NgModel!

I get the following error when using [textMask] on an input:

ORIGINAL EXCEPTION: No provider for NgModel!

My input:

  <input type="tel"
            class="form-control"
            ngControl="secondaryPhone"
            id="subjectsecondaryPhone"
            placeholder="(999) 999-9999"
            [textMask]="{mask: '(111) 111 1111'}"
            [(ngModel)]="subject.secondaryPhone"
            #secondaryPhone="ngForm"">

My component:

import { Component, OnInit } from '@angular/core';
import { FormBuilder, Validators, ControlGroup } from '@angular/common';
import { Router } from '@angular/router';

import { Subject, SubjectService } from '../shared';

import MaskedInput from 'angular2-text-mask'

@Component({
  moduleId: module.id,
  templateUrl: 'subject-detail.component.html',
  styleUrls: ['subject-detail.component.css'],
  directives: [MaskedInput],
  providers: [ValidatorsService]
})
export class SubjectDetailComponent implements OnInit {
  subject: Subject;
  subjectDetailsForm: ControlGroup;


  constructor(
    private _subject: SubjectService,
    private _fb: FormBuilder,
    private _validate: ValidatorsService
  ) { }

  ngOnInit() {

    // Subject details form
    this.subjectDetailsForm = this._fb.group({
      name: ['', Validators.required],
      dob: ['', Validators.compose([
        Validators.required,
        this._validate.date
      ])],
      gender: ['', Validators.required],
      race: ['', Validators.required],
      address: ['', Validators.required],
      primaryPhone: ['', Validators.required],
      secondaryPhone: ['']
    });
  }

}

Make email mask addon

A mask function that formats input as email is possible to write. As a convenience to users, I'll write one and publish it as addon.

Cannot call method 'update' of undefined

I'm getting the following error in my production server using the React component:

TypeError: Uncaught TypeError: Cannot call method 'update' of undefined

Stack trace is not very useful other than:
webpack:///./~/react-text-mask/dist/reactTextMask.js:1t.MaskedInput.o.default.createClass.componentDidUpdate

I'm still investigating will update with my findings.

Angular 2: No provider for NgControl

I am running the plugin as per demo, with the only apparent difference being my bootstrap code:

bootstrap(AppComponent, [
  disableDeprecatedForms(),
  provideForms(),
]);

And I get exception No provider for NgControl. Does the Angular 2 plugin only support deprecated forms?

error npm install continue

I tried, but im receiving the follow error:

#58

C:\dev\angular\text-mask>npm install
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\dev\nodejs\node.exe" "C:\dev\nodejs\node_modules\npm\bin\npm-cli.js" "install"
npm ERR! node v4.4.6
npm ERR! npm v2.15.5
npm ERR! code EPEERINVALID

npm ERR! peerinvalid The package [email protected] does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer @angular/[email protected] wants [email protected]
npm ERR! peerinvalid Peer @angular/[email protected] wants [email protected]

npm ERR! Please include the following file with any support request:
npm ERR! C:\dev\angular\text-mask\npm-debug.log

not running in RC1

I was trying to bring this to work with Angular2 RC1, but renaming of all the dependencies fom angular2/ to @angular/ seems not to be enough.
The import path is not recognized. I tryed to import {MaskedInputDirective} from '@msafi/angular2-text-mask/src/angular2TextMask';
but next problem was here: Cannot resolve 'file' or 'directory' ../../core/src/index
Do I have to install something else? Your doc only tells from "npm i @msafi/angular2-text-mask --save"

Select all, add value defaults to cursor position 0

Mask: 1111
User selects all
User presses 3

Cursor position will be moved back to 0 instead of position 1.
Only tested in React at the moment, I'll have a look at this later if I get a second before I leave.
highlighallbug

Remove React peer dep

It'd be great to remove the peer dependency on react since it doesn't really matter, or at least set it up to work with latest v15.

Project looks great though, been having android issues with masking, so glad this is being tackled in this project.

Angular 2 - Mask not working

ORIGINAL EXCEPTION: No provider for NgControl!

When i put " ngControl " in the component to the provider this error pops up:

EXCEPTION: TypeError: this.ngControl.viewToModelUpdate is not a function

Any solution for this?

text-mask does not validate partial pattern when submit form

Hi guys, it is not a issue,I am sory. I am just trying to get some help about textMask validation. Cause I could not use to invalidate the form. Thanks in advanced.

  1. html
    [textMask]="{mask: mask, validator: mmddyyyyValidator}"

  2. @component(...)
    export class Form {
    ....
    mmddyyyyValidator = createMmddyyyyValidator({
    minimumDate: '01/01/1900',
    maximumDate: '12/31/2016'
    });
    .....
    }

function createMmddyyyyValidator({minimumDate = '', maximumDate = ''} = {}) {
return function(conformedUserInput) {
return false;
}
}

Angular 2 component does not mask initial value

This is my field:

<input [(ngModel)]="telephone" [textMask]="{mask: '(11) 11111-1111'}" ngControl="telephoneControl" type="text" />

When I populate the "input" in ngModel. The page load without mask. But when i change it or add a caracter the mask works again.

Defining an onBlur causes extra character

In React defining an onBlur is causing something weird to happen.
My mask mask="111-111-1111"
Resulting value with an onBlur can cause this result.
"111-111-11113"

                        <MaskedInput
                          type="text"
                          className="form-control"
                          id="input-contact-phone"
                          placeholder="555-555-5555"
                          onBlur={() => onBlur("primaryPhoneNumber")}
                          mask="111-111-1111"
                          value={this.props.application.business.primaryPhoneNumber}
                          onChange={this.sendToRedux}
                        />

No issues with onBlur not set

                        <MaskedInput
                          type="text"
                          className="form-control"
                          id="input-contact-phone"
                          placeholder="555-555-5555"
                          mask="111-111-1111"
                          value={this.props.application.business.primaryPhoneNumber}
                          onChange={this.sendToRedux}
                        />

Consider switch to Uncontrollable

This is something I can tackle, just setting a placeholder issue.

Consider switching to using https://github.com/jquense/uncontrollable for the React portion. This would allow us to have an uncontrolled (value etc existing on internal state), as well as having a controlled input (user controlled what value is).

Just will make the component more flexible

If passed a number instead of string will throw

If passed a number instead of a string split is called and will cause an error to be thrown.
May only be an issue with React.

Not sure if we should always coerce to strings? It's handleable in user land so not pressing for a fast fix, curious of what you think should be done.

React can't have empty placeholder

If you define an empty placeholder placeholder="" the component doesn't allow for this and will just render the placeholder it constructs.

To-dos

  • Add contributing instructions
  • See if, some how, component tests can be shared rather than having to write separate tests for each component (because all component tests look the same)
  • Use FlowType
  • Add report of test coverage
  • Let mask take a function?
  • Achieve feature parity with https://github.com/RobinHerbots/jquery.inputmask
  • Support elastic pattern areas
  • Support adjustCaretPosition when deleting with "alt" down
  • Support right-to-left languages
  • Support non-English languages
  • Allow a masking character to be used as part of the pattern
  • Move integrations to root level
  • Support adjustCaretPosition when pasting
  • Support adjustCaretPosition when modifying a full mask
  • Fix test case in adjustCaretPosition
  • Add license info to READMEs
  • Mention example files and folders in READMEs of integrations
  • Add links to the source code of integrations in their READMEs
  • Add syntax highlighting to code on website
  • Create a test suite for high-level behavior (A test suite for UI components to be tested againt to verify that they are working properly)
  • Run tests on compiled code
  • Hook up a CI
  • Add ESLint
  • Remove dependency on jsdiff

Make components for:

  • Vue
  • Angular 1
  • Cycle
  • Ember 1
  • Ember 2
  • React Native (This one's not possible yet because React Native has no way to adjust caret position in a text field)
  • React
  • Vanilla
  • jQuery
  • Angular 2

Bug resolve in angular 2 (Input is populated)

The input populated bug is resolved, but i can't push my modifications "Permission denied":

The change was this: angular2TextMask.ts

ngOnInit() {
const {placeholderChar} = this.textMaskConfig

this.control = createTextMaskInputElement(Object.assign({
  inputElement: this.inputElement,
  placeholderChar,
}, this.textMaskConfig))

**this.control.update()**

}

Someone can publish this alteration or verify it?

Character count wildcard (eg price mask)

I can't find in the docs and examples, so I'm assuming this is not implemented.

I'm consuming price value in integer cents, that I need to display as decimal. For example, I have a 15000 value that has to be displayed as 150.00. That is easy to do in a read-only situation, but I need to mask this in a input. Is it possible to do something like {mask: '1+.11'},{mask: '1*.11'} or similar?

Angular 2 validators do not work

On first type I have:
RIGINAL EXCEPTION: TypeError: this.ngControl.viewToModelUpdate is not a function
And ngModel do not changing

And what about form.valid?

Unwanted extra character

I'm not sure if this is a bug or I'm doing something wrong.

Using angular2 rc.4, angular2-text-mask 0.15.

Masking like this.
<input [textMask]="{mask: '11/11/1111'}" type="text" formControlName="dob" required>

The mask displayed in the form is correct _ _ / _ _ / _ _ _ _ but If I enter a date like 01/12/1992 there is always an extra _ saved at the end in the background, 01/12/1992_. If I enter 01/12/19923, I don't actually see the last 3 get typed into the input but it saves it as 01/12/19923. Anything beyond that though it doesn't take. Thanks for looking!

Ionic v2 compatibility

Is it possible to host the mask directive with a custom input component? Like <ion-input> from Ionic Framework

Angular 2 Import

Hi. Can't import module because ts can not find module. Packege was instaled by npm.

image

Thanks!

[Webpack] Can't install in Angular2 RC4

Hi,

I'm trying to install your module but I've the following error:
`npm ERR! node v4.4.5
npm ERR! npm v2.15.5
npm ERR! code EPEERINVALID

npm ERR! peerinvalid The package [email protected] does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer @msafi/[email protected] wants angular2@*`

Do you have any idea why it's complaining about angular2?
In my package.json, Angular is defined like this:
"@angular/common": "2.0.0-rc.4", "@angular/compiler": "2.0.0-rc.4", "@angular/core": "2.0.0-rc.4", "@angular/forms": "0.2.0", "@angular/http": "2.0.0-rc.4", "@angular/platform-browser": "2.0.0-rc.4", "@angular/platform-browser-dynamic": "2.0.0-rc.4", "@angular/router": "3.0.0-beta.2"

Thanks in advance.

Benjamin

Allow to input characters, those are in mask, but aren't masked

At first, thanks for the great plugin! ๐Ÿ‘

It is a question of usability and matching a mask to a value in a brain. When you see "(" in a mask, you are ready to input it :) I think.

How to reproduce / actual

  1. Open https://msafi.github.io/text-mask
  2. Enter the mask: "(111) 111-1111" (without quotes). In the masked input you will see "(__) -"
  3. Focus on "Masked input" and try to press "(".
  4. Nothing happens, "(" is not appended to input.

Expected

When you presses "(", it is appended to input and you will able to enter the next character.

What do you think?

Error on install

Installing with this command:

npm i angular2-text-mask --save

Gives me the following error:
corp-segurado@ C:\Projetos\corp-segurado\app
+-- UNMET PEER DEPENDENCY angular2@*
+-- [email protected]
`-- [email protected] extraneous

Why is this happening and how could I solve this?

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.