I am working with material and want to have a numeric input. Using the solution they provide in the documentation isn't working:
<TextField inputProps={{ inputMode: 'numeric', pattern: '[0-9]*' }} />
It looks like a feature for future. But I wanted to know what is the best way to work around numeric input using material ui and only accept number as input. Currently I can type letter in the text field
In your case, you can change the inputMode:'numeric'
to type:'number'
and remove the pattern property. You can try the code snippet like this:
<TextField inputProps={{ type: 'number'}} />
This will only accept number as input.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With