my input field is showing letters it recieved as inputs althogh its state is not updated due to the test i have at the onchange event. for example: input field="dldld" and the state will be "".
my onchange function:
const handleChangeAdRentContent = (e) => {
const re = /^[0-9\b]+$/;
if (e.target.min) {
if (e.target.value === "" || re.test(e.target.value)) {
const name = e.target.name;
const value = e.target.value;
setInputAdConentRent({ ...inputAdConentRent, [name]: value });
return;
} else {
return;
}
}
};
this is the input field:
<label
key={masters[index].name + masters[index].adID}
className={notdisplayRent}
>
<span>{masters[index].free_text}</span>
<input
type="text"
name={masters[index].name}
min={masters[index].min_value}
max={masters[index].max_value}
id={masters[index].name}
required={masters[index].required}
value={inputAdConentRent.name}
onChange={handleChangeAdRentContent}
/>
</label>
this is the input it consitst of an object of many inputs controlled by [key,value]
const [inputAdConentRent, setInputAdConentRent] = useState({});
thank you very much