Design comparison
Solution retrospective
Hello good ppls
I tried using CSS grid template areas for this one, since it seemed convenient for rearranging the layout at different screen sizes (was this a good choice?)
I also used Gulp and SASS after watching a tutorial about it, and split my SASS files up. I'm aware I'm using the depreciated @import here, but I haven't learned the replacements yet.
The form and button is very clumsy. There's a lot to clean up there.
JS is a big weakness of mine, and you'll see I had trouble with it here. I'm not quite understanding the 'click' event listener. I don't consider this part of the challenge to be finished - any feedback or tips on how to fix it up would be appreciated!
Community feedback
- @tankop1Posted about 3 years ago
A couple tips:
-
Your event listener may not be working for a couple reasons. First of all, you should either use the
onclick
attribute in your HTML, OR the.addEventListener('click', eventHandlerFunction);
, not both. Also, make sure to attach the event listener to the button itself, not the image inside of the button. Lastly, because the button is inside the form element, the browser automatically reloads the page every time the button is clicked, which will remove your error message. To stop this from happening, you can usee.preventDefault();
at the top of your "validateEmail" function to avoid the browser's default behaviors (e.g. reloading the page) when a form button is clicked. -
Instead of using
type="text"
in for your inputs, it would make much more sense to usetype="email"
. This code is more semantic, and also lets you use tools such as the:valid
pseudo-class to change the styling of the input based on if the email is valid.
Marked as helpful0@jordy-whitePosted about 3 years ago@tankop1 Thanks so much for the great feedback! I made a few changes based on it. I still have a problem getting the error logo to show when the email is invalid.
if (input.value.match(emailRegex)) { errorLogo.style.display = "none"; } else { errorLogo.style.display = "block"; } };
I can't work out why this isn't working. Any ideas?
0@tankop1Posted about 3 years ago@meatpies I think the problem here is actually in your HTML: When giving an element more than one class, make sure to put all the classes in the same class attribute (e.g.
class="form-button submit"
instead ofclass="form-button" class="submit"
).Hopefully this should work (:
0 -
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