inputmask-core icon indicating copy to clipboard operation
inputmask-core copied to clipboard

allow special characters at the beginning of pattern

Open agapas opened this issue 9 years ago • 5 comments

it stops work when you delete all characters from the input for pattern such as '(111) 111-1111', but still works for pattern '111) 111-1111'

agapas avatar Aug 25 '15 08:08 agapas

Can you provide details on how to reproduce this?

A failing addition to the 'Leading static characters' test case would be ideal.

insin avatar Sep 11 '15 16:09 insin

@agapas currently plugin expect that you provide mask characters if you insert at begin of input, like mask.paste('(123)456-7890')

AuthorProxy avatar Jun 23 '16 20:06 AuthorProxy

@AuthorProxy Thanks for the clarification. I have the same issue with this pattern. Following your example, in order to work with (111)-111-1111 pattern, I'd need to do mask.paste('(1234567890'), since I want it to be masked for me, and not actually provide masked input.

If I read the code correctly, the intented behaviour of mask.paste() is to accept both masked and unmasked values (as mentioned here). Hovewer,

  // If there are static characters at the start of the pattern and the cursor
  // or selection is within them, the static characters must match for a valid
  // paste.

the code that checks the first character does not account for unmasked value as the first charater, and has to match exactly the static charater (that is missing, since it's unmasked). Hence, mask.paste('1234567890') will fail because of the first character, but mask.paste('(1234567890') will succeed because the rest of the paste (after the first character) supports unmasked value.

This is not a dealbreaker, the workaround is to loop through the string and do mask.input(char) instead, I just thought I'd clarify the issue we had working with this pattern.

thanks

onebit0fme avatar Oct 03 '16 14:10 onebit0fme

not working mask.paste with +7(111)-111-11-11

Khangeldy avatar Mar 06 '17 16:03 Khangeldy

Thank you i understand it. Sorry my bad english. Solution is mask.paste("+7(" + rest number).

Khangeldy avatar Mar 06 '17 16:03 Khangeldy