Mel Carlo Iguis
Mel Carlo Iguis

Reputation: 156

How to input decimal places in Textfield from MUI in react

I try to input with some decimal but I got this prompt message from my min-max value.

and this is my Textfied element

<TextField
  type="number"
  InputProps={{ inputProps: { min: 36, max: 40 } }}
  onFocus={() => handleOnFocus('bodyTemp')}
  onChange={(e) => setBodyTemp(e.target.value)}
  value={bodyTemp}
 />

enter image description here

Upvotes: 4

Views: 6816

Answers (1)

Nikhil G
Nikhil G

Reputation: 2466

Add step attribute.

 <TextField
  type="number"
  step="any"
  InputProps={{ inputProps: { min: 36, max: 40 } }}
  onFocus={() => handleOnFocus('bodyTemp')}
  onChange={(e) => setBodyTemp(e.target.value)}
  value={bodyTemp}
 />

Upvotes: 0

Related Questions