From 45e85b290dcc53e014f1ab5d8e2327801d9855ed Mon Sep 17 00:00:00 2001 From: melkamu372 Date: Fri, 8 Sep 2023 16:58:17 +0300 Subject: [PATCH] validate to add empty education --- src/component/Education.jsx | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/component/Education.jsx b/src/component/Education.jsx index ff8322d..95f7fb1 100644 --- a/src/component/Education.jsx +++ b/src/component/Education.jsx @@ -1,4 +1,3 @@ - import {React, useState, useEffect} from "react"; import Button from "./Button"; function Education() { @@ -35,6 +34,20 @@ function Education() { }); }; const AddNewEducation=()=>{ + + + if (formData.school.trim() === "") { + alert("Please enter a school name."); + return; + } + if (formData.level.trim() === "") { + alert("Please enter Education Level"); + return; + } + if (formData.department.trim() === "") { + alert("Please enter department name."); + return; + } setEducationalInfo((prevData) => [...prevData, formData]); setFormData({ school: "", @@ -92,20 +105,14 @@ function Education() { -
-
- -
- -
+
-
+
{education.length > 0 ? ( - +
- + - + {education.map((edu, index) => ( @@ -142,7 +149,6 @@ function Education() { ) : (

No users registered yet.

)} - );
School Level Departement Action
{edu.school}