How to allow only English letters in input fields?

So, this is my input field:

<input type={type} name={name} />

How can I allow only English letters?

This is the RegEx, I believe I should use: /[A-Za-z]/ig

I am assuming that onChange() event should be used for this with the combination of setState() and


PS. I need to have this WHILE typing.


I would try this onChange function:

onChange={(e) => {
  let value =

  value = value.replace(/[^A-Za-z]/ig, '')


See the codepen:

The idea is to reverse your regex matcher with ^ and replace all non-A-z characters with ''