Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Andrew Terrett](https://secure.gravatar.com/avatar/43252897c5e4582cc2336ea8ca2d026c?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Andrew Terrett
1,984 PointsAlert box is not popping up for me can someone check my code?
When I try and run the code the alert box is not popping up in the browser when I check the console it says uncaught typeerror cannot read properties of null.
can someone let me know where I'm going wrong here?.
function isFieldEmpty() {
const field = document.querySelector('#info');
if (field.value === ''){
return true;
} else {
return false;
}
}
const fieldTest = isFieldEmpty();
if (fieldTest === true) {
alert("Please provide your information.");
}
2 Answers
![Rohald van Merode](https://uploads.teamtreehouse.com/production/profile-photos/11666882/micro_Rohald-profile.jpg)
Rohald van Merode
Treehouse StaffHi Andrew Terrett 👋
This snippet of code looks great to me and should be working as expected 😃
This error usually means that you're trying to target an element that does not exist. Could you have a look at the index.html
file and make sure that you've uncommented the input element on line 10 as Guil shows at 1:16?
Hope this helps! 🙂
![Andrew Terrett](https://secure.gravatar.com/avatar/43252897c5e4582cc2336ea8ca2d026c?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Andrew Terrett
1,984 PointsHey!
Thanks for getting back to me! I have checked the input element and it is uncommented I know for sure its something I have done wrong I just really cant figure out what it is lol.
![Rohald van Merode](https://uploads.teamtreehouse.com/production/profile-photos/11666882/micro_Rohald-profile.jpg)
Rohald van Merode
Treehouse StaffHm... I'm not entirely sure what could be the issue then, I've copy/pasted your code into a workspace on my end, uncommented the input field and adjusted the script path to link the correct .js file and everything was working for me 🤔
If you're still having issues with this feel free to create a snapshot of your workspace. By doing this it'll generate a link you can share for others to see your exact code. This makes it easier for us to see what might be causing the issue 🙂