import { useState } from "react"; import Button from "../Button"; import Dropdown from "../Dropdown"; const Form = () => { const [formData, setFormData] = useState({ name: "", email: "" }); const [errors, setErrors] = useState({}); const handleChange = (e) => { const { name, value } = e.target; setFormData({ ...formData, [name]: value }); }; const validate = () => { let newErrors = {}; if (!formData.name) newErrors.name = "Name is required"; if (!formData.email) { newErrors.email = "Email is required"; } else if (!/\S+@\S+\.\S+/.test(formData.email)) { newErrors.email = "Email is invalid"; } return newErrors; }; const handleSubmit = (e) => { e.preventDefault(); const validationErrors = validate(); if (Object.keys(validationErrors).length === 0) {
Form Filled Successfully
} setErrors(validationErrors); }; const approveText = () => { setTimeout(() => {Form Filled Successfully
},1000) }; return ( <> > ); }; export default Form;