i would like keep the value written in the input, but antd always modify the number
for example,
case 1: if write 3.5 should be 3.5
case 2: if write 3,5 should be 3,5
this is the code:
import React from 'react';
import { InputNumber } from 'antd';
const onChange = (value) => {
console.log('changed', value);
};
const App = () => <InputNumber min={1} max={10} defaultValue={3} onChange={onChange} />;
export default App;
when i written 3.5 is keeping 3.5 its ok
but when i typed 3,5 the value is changing to 10
2
Answers
I haven’t worked with
antd
but the issue you’re seeing could be due to the parsing of the number, where when you use a,
the number is interpreted is such a way that the max is reached.You could try adding a parser function that interprets the result:
This is a pretty loose example, there’s probably a better way to do this that better fits your use case.
you can custom Input using onchange