From 0ef4f1536a021f40b31ac2904bb82229530eb4e1 Mon Sep 17 00:00:00 2001 From: keyserfaty Date: Thu, 28 Sep 2023 07:38:41 -0300 Subject: [PATCH] fix for domain names --- index.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 225d64b..e895e87 100644 --- a/index.js +++ b/index.js @@ -103,10 +103,18 @@ const $errorMsg = document.querySelector('.step-5-error') - const invalidEmail = !REGEX_VALID_EMAIL.test($form.value) || FORBIDDEN_DOMAINS.includes($form.value) - $errorMsg.style.display = invalidEmail ? 'block' : 'none' + if (REGEX_VALID_EMAIL.test($form.value)) { + const emailDomain = $form.value.split('@')[1].split('.')[0] - return invalidEmail + if (FORBIDDEN_DOMAINS.includes(emailDomain)) { + $errorMsg.setAttribute('style', 'display: block;') + return true + } + + return false + } + + return true } default: