Design comparison
SolutionDesign
Community feedback
- @shakhboz-shukhratPosted over 1 year ago
Hello there👋! Congratulations on completing this challenge!
const imagemErro = document.querySelector('#imagem'); const emailRegex = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/; function botao(){ if(email.value === ''){ imagemErro.classList.add('des'); email.style.border = '1px solid red'; } else { imagemErro.classList.remove('des'); email.style.border = ''; } validate(); } function validate(){ if(emailRegex.test(email.value)){ imagemErro.classList.remove('des'); email.style.border = ''; } else { imagemErro.classList.add('des'); email.style.border = '1px solid red'; } }
Changes made: The variable
imagErro
was replaced withimagemErro
to match its ID in the HTML. Semicolons were added to the end of lines.A strict equality comparison (
===
) was used instead of a loose one (==
). Spaces were added afterif
andelse
statements for consistency.The
validate()
function is now being called at the end of thebotao()
function.Wanted to mention that this is very good solution! Great work!
Marked as helpful0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord