I have an input field where i am trying to block the special characters [dot, hiphen, space comma and e] so that user can’t enter this special characters on both mobile and chrome.
export default function App() {
const handleInput = (event) => {
event.target.value = event.target.value.replace(/[e.- ]/g, "");
};
return (
<div className="App">
<input type="number" onInput={handleInput} />
</div>
);
}
Facing two issues on this, one is (999.) I am able to enter dot in between numbers, also when I enter some numbers and type hiphen then its clearing all the numbers (999-) => ().
How can I stop this two behaviour so that user can enter only 0-9 digits