Check out example codes for "html restrict input to numbers". It will help you in understanding the concepts better.

Code Example 1

<input type="text" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');" />

Code Example 2

<input type="number" id="quantity" name="quantity" min="1" max="5">

Learn ReactJs, React Native from akashmittal.com