diff --git a/frontend/src/Login/Signup.tsx b/frontend/src/Login/Signup.tsx index dae3dd83..b39802fd 100644 --- a/frontend/src/Login/Signup.tsx +++ b/frontend/src/Login/Signup.tsx @@ -1,11 +1,32 @@ -import React from 'react'; +import React, { useState } from 'react'; import DocsGPT3 from '../assets/cute_docsgpt3.svg'; import { useNavigate } from 'react-router-dom'; export default function Signup() { + const [showalert, setshowalert] = useState(''); + const [email, setemail] = useState(''); + const [password, setpassword] = useState(''); + 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'); + return; + } + alert('Signup Successful '); navigate('/login'); @@ -34,27 +55,34 @@ export default function Signup() { type="email" name="Name" placeholder="Email" + onChange={(e) => { + setemail(e.target.value); + }} className="w-full rounded-lg border-none bg-[#2B2B2B] p-4 text-sm font-medium text-white focus:outline-none md:min-w-[25vw]" - // onChange={onchange} /> { + setpassword(e.target.value); + }} className="w-full rounded-lg border-none bg-[#2B2B2B] p-4 text-sm font-medium text-white focus:outline-none md:min-w-[25vw]" - // onChange={onchange} /> - + {showalert.length > 0 && ( +
{showalert}
+ )}

Already have an account ?

navigate('/login')} > - Log in + log in