GoncharukOrg / react-input

109 stars 9 forks source link

onBeforeInput value is actual value #19

Closed rickanutyi closed 6 months ago

rickanutyi commented 9 months ago

Hi, i am using react-input/mask

<InputMask ref={forwardedRef} mask="996(___)___-___" replacement="_" showMask type="number" {...props} />

The problem is, 

When a user pastes a copied value, for example, 996333222111, the input value should be formatted as 996(996)333-222. I would like to have a method where I can get the value before it is processed by the mask, so I can determine if '996' is already present in the value entered by the user and remove it.

I tried to use onBeforeInput or onBeforeInputCapture? but thay give me value as 996(996)333-222

rickanutyi commented 9 months ago

I just realized there is data field that has value i need. image But typescript dont know about it. And i need to change the value that way image I dont think it right way to work with react

GoncharukBro commented 9 months ago

We are currently working on being able to change the value before masking the input, we will include this feature in the next release.

GoncharukBro commented 7 months ago

The new version adds the track method, with which you can conditionally change the entered value.

You can intercept input to change the entered value every time the value in the input element changes. See Track.

npm i @react-input/mask@latest