maska icon indicating copy to clipboard operation
maska copied to clipboard

Unexpected behavior with "(##) 9####-####" mask

Open juanbelieni opened this issue 3 years ago • 2 comments

I'm trying to add a mask to a phone input in Brazilian format. So I'm using (##) 9####-#### as the mask, but the input after (##) 9 does not accept any number other than 9:

image

juanbelieni avatar Dec 27 '21 17:12 juanbelieni

I also use it for Brazilian standard, what I did was simply pass an array with I want the mask to apply to the input

Ex: ['(##) ####-####', '(##) #####-####']

rbarbosa95 avatar Jan 13 '22 21:01 rbarbosa95

I can confirm this. One option: <input v-maska="{ mask: '(##) Z ####-####', tokens: { 'Z': { pattern: /[9-9]/ }}}" class="form-control" placeholder="Ex: (41) 9 91233-4567" type="text">

jakjr avatar Apr 21 '22 10:04 jakjr

Should be fixed with v2

beholdr avatar Dec 04 '22 15:12 beholdr

@beholdr if I use the following example, the method completed return wrong https://codesandbox.io/s/maska-i37oj7

import { Mask } from "maska";

const mask = new Mask({ mask: ["(##) ####-####", "(##) #####-####"] });

const value = "(64) 3453-3469";

const obj = {
  value: value,
  masked: mask.masked(value),
  unmasked: mask.unmasked(value),
  isValid: mask.completed(value)
};

mask.completed it should return true, but return false.

renerlemes avatar Apr 14 '23 17:04 renerlemes