Answer the question
In order to leave comments, you need to log in
How to allow only English characters to be entered?
I googled and found only this:
<input
type="text"
onKeyPress={(e) => validation(e)}
/>
const validation = (e) => {
let input = e.target.value;
input = input.replace(/[A-Za-z]/, '');
};
Answer the question
In order to leave comments, you need to log in
const validation = (e) => e.target.value = input.replace(/[A-Za-z]/g, '');
<input
type="text"
onChange={validation}
/>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question