From 8c1ee02e2d456e8330064163b795c5428d5696d7 Mon Sep 17 00:00:00 2001 From: Hemant2335 Date: Sat, 25 Nov 2023 20:06:55 +0530 Subject: [PATCH] Final_PR_Push --- frontend/src/Login/Signup.tsx | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/frontend/src/Login/Signup.tsx b/frontend/src/Login/Signup.tsx index b39802fd..a69621a0 100644 --- a/frontend/src/Login/Signup.tsx +++ b/frontend/src/Login/Signup.tsx @@ -10,23 +10,18 @@ export default function Signup() { const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); - //email validation if (email.length === 0 || password.length === 0) { - if (password.length === 0) { - setshowalert('Password is required'); - return; - } else { - setshowalert('Email is required'); - } - return; - } else { - setshowalert(''); - } - if (password.length === 0) { - setshowalert('Password is required'); + setshowalert('Both fields are required'); return; } + //email validation + if (!email.match(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/)) { + setshowalert('Please enter a valid email address'); + return; + } + + setshowalert(''); alert('Signup Successful '); navigate('/login'); @@ -69,7 +64,7 @@ export default function Signup() { }} className="w-full rounded-lg border-none bg-[#2B2B2B] p-4 text-sm font-medium text-white focus:outline-none md:min-w-[25vw]" /> - {showalert.length > 0 && ( @@ -79,7 +74,7 @@ export default function Signup() {

Already have an account ?

navigate('/login')} > log in