I'm trying to set up a phone number input in react-hook-form library.
I set input type to number, but it still accepts "e" and "-" chars.
I tried to prevent it like this:
<Controller
name="phone"
control={control}
rules={{ required: true }}
render={({ onChange, value, ref }) => (
<Input
ref={ref}
type="number"
label="phone"
onChange={(e) =>
/[^e]/.test(e.target.value) && onChange(e.target.value)
}
val={value}
/>
But it doesn't work properly. Any recommendations how to solve this problem?