diff --git a/frontend/vanilla/html/login.html b/frontend/vanilla/html/login.html index a619827..3357c43 100644 --- a/frontend/vanilla/html/login.html +++ b/frontend/vanilla/html/login.html @@ -83,7 +83,7 @@
-

Don't have an account? Register

+

Don't have an account? Register

@@ -133,12 +133,26 @@ * calls. Retrurns true or false */ function validateFields(){ - const email = document.getElementById("email").value; - const password = document.getElementById("password").value; - if(!email || !password || !validateEmail(email) || password.length < 5){ - return false; + const emailField = document.getElementById("email"); + const passwordField = document.getElementById("password"); + var isFormValid = true; + + if(!emailField.value || !validateEmail(emailField.value)){ + emailField.classList.add("is-invalid"); + isFormValid = false; } - return true; + else{ + emailField.classList.remove("is-invalid"); + } + + if(!passwordField.value){ + passwordField.classList.add("is-invalid"); + isFormValid = false; + } + else{ + passwordField.classList.remove("is-invalid"); + } + return isFormValid; } /* diff --git a/frontend/vanilla/html/register.html b/frontend/vanilla/html/register.html index 032ce7b..bf4b3c6 100644 --- a/frontend/vanilla/html/register.html +++ b/frontend/vanilla/html/register.html @@ -112,7 +112,7 @@

-

Already have an account? Already have an account? Sign in

diff --git a/frontend/vanilla/js/utils.js b/frontend/vanilla/js/utils.js index 63beb44..b182b07 100644 --- a/frontend/vanilla/js/utils.js +++ b/frontend/vanilla/js/utils.js @@ -14,7 +14,7 @@ function getCookie(name) { * Validates an e-mail using a RegExpression * * @param {*} email - * @returns + * @returns true or false */ function validateEmail(email) { return String(email)