I am creating an input field where the user can only type numbers or decimal numbers. If text is typed, it clears the entire input. I want to prevent users from typing text without clearing the field. Any suggestions on how to achieve this?
<input
type="text"
id="willBeCreditedAmount"
maxLength={9}
placeholder="Enter amount"
pattern="[0-9]*"
onChange={(e) => this.props.updateWillBeCreditedAmount(e.target.value, currentComProfile)
}
value={willBeCreditedAmount}
/>