We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
// Validate that none of the fields are empty
if (!name.trim() || !email.trim() || !message.trim()) {
setError("All fields are required.");
setSubmittedData(null); // Clear submitted data if validation fails
} else {
setError(""); // Clear any existing errors
setSubmittedData({ name, email, message });
// Clear input fields after successful submission
setName("");
setEmail("");
setMessage("");
}
};
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Contact Form
You are viewing a single comment's thread. Return to all comments →
const handleSubmit = (e) => { e.preventDefault();
// Validate that none of the fields are empty if (!name.trim() || !email.trim() || !message.trim()) { setError("All fields are required."); setSubmittedData(null); // Clear submitted data if validation fails } else { setError(""); // Clear any existing errors setSubmittedData({ name, email, message });
} };