Skip to content

Commit

Permalink
Added validation to alert users for empty form submissions
Browse files Browse the repository at this point in the history
  • Loading branch information
amantaphelix committed Jul 27, 2024
1 parent 7c29c34 commit f4a121d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/pages/ContactUs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ const Contact = () => {

const handleEmailSubmit = async (e) => {
e.preventDefault();
if (!form.name || !form.email || !form.message) {
alert("Please fill in all fields before submitting.");
return; // Stop further processing if form is incomplete
}
setLoading(true);

try {
Expand Down Expand Up @@ -62,6 +66,10 @@ const Contact = () => {
};
const handleSaveToDB = async (e) => {
e.preventDefault();
if (!form.name || !form.email || !form.message) {
alert("Please fill in all fields before submitting.");
return; // Stop further processing if form is incomplete
}
setLoading(true);

try {
Expand Down

0 comments on commit f4a121d

Please sign in to comment.