Design comparison
Community feedback
- @heisemmaco-devPosted 11 months ago
Hey Ega, you did i really good job there with design and also with javascript but there is one thing that you didn't get well
The issue lies in the if statement checking if the email input is empty. Currently, it uses email.value === "" to verify emptiness. However, this condition doesn't account for spaces, so if spaces are entered, it still registers as content in the input.
To solve this, consider using email.value.trim() for the condition. This adjustment checks if there's no content after trimming spaces. So, the updated code would look like this: if (email.value.trim() === "") { email.style.outlineColor = "red"; errorMsg.textContent = "Email cannot be empty"; } Now, it'll properly identify an empty input, including cases where there might be only spaces. This way, the form validation becomes more accurate.
I hope your fine this helpful
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