Design comparison
Solution retrospective
This was a fun project to complete. I think I got the styling as close as I could, but I have a question regarding my JavaScript. It sends the right error message and colors until I enter a valid email address (one that contains the '@' symbol). After that, if I enter an invalid email, all error text is black. Would that matter on a real website if the user was redirected to another page after submitting a valid email anyway? Please let me know and also let me know if you find any errors or see any areas for improvement in the overall code.
Thanks!
Community feedback
- @abhik-bPosted almost 4 years ago
Hi Zach, Your solution is very responsive and seems perfect 🔥🔥
Actually why the text is becoming black after a valid email entry is this code block:
else if (inputValue && inputValue.includes('@')) { errorText.innerText = '.'; errorText.style.color = 'black'; }
In the above code you set the error's (** inline style** ) text color to black and inline-style is given priority when a css property has different values in css files.
However , when you enter a invalid email after that valid entry any of the below code blocks are run :
if(!inputValue){ errorText.innerText = 'Oops! Please add your email'; errorText.classList.add('textContainer__error--visible'); } else if (!(inputValue.includes('@')) && inputValue){ errorText.innerText = 'Oops! Please check your email'; errorText.classList.add('textContainer__error--visible'); }
In the above code block you change the text of the error but its
color
is set to black only (inline-styles), you need to add something likeerrorText.style.color = 'red'
to make it have red color again.Hope this is useful to you, and keep on contributing this amazing solutions 🚀
2@zky63Posted almost 4 years ago@abhik-b Thanks for the in-depth comment. I don't know why I tried to over-complicate it by adding classList to the JS. But I used what you said and it worked perfectly.
1@abhik-bPosted almost 4 years ago@zky63 Hey Zach, I again took a look at your solution and it works perfectly now , glad my feedback was useful to you😇
1
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