From 0e168267b1a3fc222b0537c187bf535b9905d126 Mon Sep 17 00:00:00 2001 From: "Rayyan (Rayy)" Date: Tue, 19 Sep 2023 09:47:10 +0000 Subject: [PATCH] Add validation for login credentials to determine if real details. --- src/pages/Signin.js | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/pages/Signin.js b/src/pages/Signin.js index 89b063b..cba0b36 100644 --- a/src/pages/Signin.js +++ b/src/pages/Signin.js @@ -6,16 +6,36 @@ import Button from "react-bootstrap/Button" import {useState, useEffect} from 'react'; export function Signin ( props ) { + const [email, setEmail] = useState('') + const [validemail, setValidemail] = useState(false) + const [password, setPassword] = useState('') + const [validpassword, setValidpassword] = useState(false) + + useEffect( () => { + if(email.indexOf('@') > 0) { + setValidemail(true) + } + else { + setValidemail( false ) + } + }, [email]) + + useEffect( () => { + if( password.length >= 8 ) { + setValidpassword(true) + } + else { + setValidpassword( false ) + } + }, [password]) + return ( -
- - - - Email + + Email