Best way to prevent NumberField
from substituting entered value when it's outside min-max range?
#8776
-
As docs say., number inputs snaps to lowest / highest possible value when user enters something out of range:
I get why this happens / it behaves like this, yet the app I'm working on is very data sensitive (medical trials) and changing values automatically is bad thing :) Haven't got to this yet, but thinking exploring couple approaches for this (not sure if they are viable yet)
Was wondering, maybe there's better approach to tackle this? (Ideally, RAC components would have prop to disable this behavior - user could enter whatever and UI would just show validation error for that field) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
After reading the html number input mdn, maybe we should have a prop to control this. https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/number#max For now though, you should be able to handle this by not setting the min/max, use a description to tell people about it, and implement your own validation for it (see link to Forms guide) |
Beta Was this translation helpful? Give feedback.
After reading the html number input mdn, maybe we should have a prop to control this. https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/number#max
And let it fail constraint validation like native controls do. I'll bring it up with the team.
For now though, you should be able to handle this by not setting the min/max, use a description to tell people about it, and implement your own validation for it (see link to Forms guide)