I am new to React and I am trying to have a input field which can take values between -40 and 30. I am using Form.Control from react-bootstrap and below is my code
interface Range{
min: number,
max: number
}
const defaultState : types.EqParamRange = {
Max: 0,
Min: -1,
};
const [stateRange, setRange] = React.useState<types.Range>(defaultState);
<Form.Group
key="min"
className="mb-3"
>
<Form.Label>Y-min</Form.Label>
<Form.Control
type='number'
disabled={!enableCustomAxis}
min={-40}
max={30}
step={1}
value={Range.Min}
onChange={(event) => {
const target = event.target as HTMLInputElement
const value = Number(target.valueAsNumber);
setCustomYAxisRange( Range => ({
...Range,
Min: value
}));
}}
required
placeholder='Enter minimum value of Y-coordinate'>
</Form.Control>
</Form.Group>
On clearing the input field, when I try to input minus sign, it does not allow me to do so. How do I resolve this?
I tried using type='text' and pattern which allows negative numbers but it does not work
setCustomYAxisRangeorsetRange?