Design comparison
Community feedback
- @Mod8124Posted about 2 years ago
Hello Well done!
it's because you have to check if the value of the input is empty
if (inputText.value.length > 1)
notif (inputText !== null)
here is checking if the variableinputText
exits and has a different value of null, and notinputText's value
I hope it helps you, Good coding π€
Marked as helpful0@SimplyvodaPosted about 2 years ago@Mod8124 Thank you for your response, this has been helpful :)
0 - @UrbanskiDevPosted about 2 years ago
Hello Vodina Efem !
Congratulation for finishing this project
Let's break things to see what's going wrong !
You start by getting the content of your input -> OK
In your function :
- You created a variable which check if it is a valid email -> OK
- Then, you made a condition to see if the content of the input is not null, and that's where the problem occur !
You used the operator !==, which means that it returns true if the input is different of null
More info can be found on the topic here :
That's mean, if the user doesn't add anything, and click the button, the input field is not null, maybe it is an empty string or an object, and if that's the case, it's different of null, and consider the condition is true. It may be an other reason, maybe you can add a default value by default of null ?
Also, a little tips : when something doesn't work as wanted, don't hesitate to do debugging by checking the value of the variable, by adding console.log() to check if it does what you want. Sometimes, you can check your browser web console by pressing F12, where errors can appear if something's wrong.
I hope it makes sense, that's it's helping you to understand what was wrong, the thought process while giving you ideas how to solve it
Marked as helpful0 - @thisisharsh7Posted about 2 years ago
Hey vodina, good job! I think there is a problem with inputText as it is a dom object you can't write this
inputText !== null
and it never equals to null so it is always true.const inputText = document.getElementById('email-text').value; //now this contains the value not any object
Try this.. I hope this will work, happy coding βοΈ.
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