From 76113ace963711fb9ee3b10f15597849d27474e5 Mon Sep 17 00:00:00 2001 From: "Rayyan (Rayy)" Date: Tue, 12 Sep 2023 10:50:24 +0000 Subject: [PATCH] Adding checks to validate user and password --- src/pages/Signup.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/pages/Signup.js b/src/pages/Signup.js index 545bc2d..c316d7e 100644 --- a/src/pages/Signup.js +++ b/src/pages/Signup.js @@ -9,8 +9,9 @@ export function Signup ( props ) { const[username,setUsername] = useState('') const[validusername,setValidusername] = useState(false) const[useremail,setUseremail] = useState('') - const[password,setPassword] = useState('') - + const[validemail,setValidemail] = useState(false) + const[password,setUserpassword] = useState('') + const[validpassword,setValidpassword] = useState(false) const submitHandler = (evt) => { evt.preventDefault() } @@ -24,6 +25,24 @@ export function Signup ( props ) { } }, [username] ) + useEffect( () => { + if(useremail.index0f('@') > 0 ) { + setValidemail(true) + } + else { + setValidemail(false) + } + }, [useremail] ) + + useEffect( () => { + if( setUserpassword.length >= 8 ) { + setValidpassword(true) + } + else{ + setValidpassword(false) + } + }, [setUserpassword] ) + return (