79565701

Date: 2025-04-10 04:10:22
Score: 1
Natty:
Report link

You are getting the "Invalid email" error because your fieldValues.email is set to false (a boolean) instead of the actual email string. The regex validation fails because it’s not checking a string.

so, change this const [fieldValues, setFieldValues] = useState({ name: false, email: false, message: false, }) to const [fieldValues, setFieldValues] = useState({ name: "", email: "", message: "", })

here, stateKey is also passing boolean value insted of string so change this code, const handleInputClick = (stateKey) => { setFieldValues({ ...fieldValues, [stateKey]: true, }) } to this, const handleInputChange = (e, stateKey) => { setFieldValues({ ...fieldValues, [stateKey]: e.target.value, }) }

Probably, this work for you.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: Krupa Patel