On your input add this
onInput={(e) => e.target.value = e.target.value.replace(/[^0-9]/g, '')}
This will only allow number characters
onInput={(e) => e.target.value = e.target.value.replace(/[^0-9.]/g, '').replace(/([^.]*\.[^.]*)\./g, '$1')}
This will allow 1 decimal to be added in addition to numbers
Leave a Reply