eduardoborges / use-mask-input

✏️ A react Hook for build elegant input masks. Compatible with React Hook Form
https://npmjs.com/package/use-mask-input
332 stars 19 forks source link

Problems with mask behavior when using 'a' or '*' for the mask template. #73

Closed Ilwel closed 7 months ago

Ilwel commented 8 months ago

When I use 'a' or '*' for the mask template, upon pressing 'Backspace' or 'Delete', the input is filled with 'B' or 'D', respectively.

I am using version 3.3.7, which I believe is the latest one.

image

image

4lisson777 commented 7 months ago

Same here! @eduardoborges

eduardoborges commented 7 months ago

Hey @Ilwel . You need to add to the mask who many "any" digits you want, min and max:

<input mask={"*{1,2}"}/>
4lisson777 commented 7 months ago

@eduardoborges I have this 'B' or 'D' when I try to delete the text, but I'm using this mask here -> 99999999-A. Can you help me please? :(

Ilwel commented 7 months ago

@eduardoborges I have this 'B' or 'D' when I try to delete the text, but I'm using this mask here -> 99999999-A. Can you help me please? :(

Have you tried using the many notation?

"99999999-A{1}", worked for me

garabedium commented 5 months ago

@eduardoborges. I'm seeing the same issue with the hook. On Backspace changes the first character to a B. Command + Backspace succeeds in clearing the input.

const registerWithMask = useHookFormMask(register);

      <input
        {...registerWithMask("testZip", "A{1}9A{1} 9A{1}9")}
        type="text"
      />