I want to convert a input type number into two decimal values in the form values, but show to user only integer when there is no decimal. for eg 1 -> 1.00 , 2.346 -> 2.34 As in the first example it should show to user only 1 but in the form values it should be 1.00
<Input
{...field}
onKeyDown={e => decimalPlace(e, form)}
type="number"
step={0.01}
value={minVal}
onChange={e => {
form.handleChange(e);
}}
id="price"
isDisabled={isSubmitting}
/>
As I am using chakra and formik, minVal here is a state which I set in decimalPlace function like below
form.setFieldValue('targetPriceMin', Number(e.target.value).toFixed(2))