diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..2a70607 Binary files /dev/null and b/.DS_Store differ diff --git a/compass/app/auth/forgot_password/page.tsx b/compass/app/auth/forgot_password/page.tsx index 9b0e37e..05323ee 100644 --- a/compass/app/auth/forgot_password/page.tsx +++ b/compass/app/auth/forgot_password/page.tsx @@ -6,14 +6,18 @@ import Paper from '@/components/auth/Paper'; import { useState, useEffect } from 'react'; function isValidEmail(email: string) { + //check email validation const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; if (email.trim() === '') { + //check if input is empty return 'Email cannot be empty'; } else if (!emailRegex.test(email)) { + //check for incorrect email format return 'Invalid email format'; } else{ + //return message for no error in input return 'If your email exists in the database, you should receive a password reset in your inbox.' } @@ -25,8 +29,10 @@ export default function Page() { const [emailError, setEmailError] = useState(''); useEffect(() => { + //when email string inputted it is checked in isValidEmail const error = isValidEmail(confirmEmail); setEmailError(error); + //button is disabled if any error is detected setIsButtonDisabled(error !== null && !error.includes('exists in the database')); }, [confirmEmail]); @@ -40,6 +46,7 @@ export default function Page() { { @@ -49,10 +56,11 @@ export default function Page() {
{emailError}
+ //if email does not meet certain criteria, then issue an error )}