-1

I'm making input that user could only type number or float number. If I type text it clears out whole input.I want forbid type text without clearing field . Any ideas how to make it?

<input
   type="text"
   id="willBeCreditedAmount"
   maxLength={9}
   placeholder="Enter amount"
   pattern="[0-9]*"
   onChange={(e) => this.props.updateWillBeCreditedAmount(e.target.value, currentComProfile)
   }
   value={willBeCreditedAmount}
/>
Yerlan Yeszhanov
  • 2,149
  • 12
  • 37
  • 67

2 Answers2

1

Try this

<input type="number"/>
SamiunNafis
  • 142
  • 2
  • 10
1

You can use this code

<form>
  <input type="number" id="myNumber" value="1">
</form>
Piyush Teraiya
  • 739
  • 4
  • 7