0

I have a number of Formik Field(s) in a FieldArray. I would need to prevent the user from pasting text in to the field. Any suggestion?

Vencovsky
  • 28,550
  • 17
  • 109
  • 176
Alessandro
  • 165
  • 2
  • 12

1 Answers1

1

You need to pass directly to the input the property onPaste and either return false or call event.preventDefault.

<input onPaste={() => return false} />

OR

<input onPaste={e => e.preventDefault()} />

But this have some browser compatibility problems.

You can relate to the javascript question of this, the only difference is that in react you pass onPaste instead of onpaste.

Vencovsky
  • 28,550
  • 17
  • 109
  • 176