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 trialKendall McCall
8,177 PointsMy alert is not working can someone spot my error?
function isFieldEmpty() { const field = document.querySelector('#info'); if (!field.value) { return true; } else { return false; } }
const fieldTest = isFieldEmpty();
if (fieldTest) { alert('Please provide your information.'); }
2 Answers
Casey Beaver
5,619 PointsMake sure you remove the comment surrounding the '#info' div on the index file. Otherwise there is nothing for the querySelector to grab. Opening up the console should give you more information as to what's going on.
Zaid Khan
12,769 PointsDid you remove the value attribute from the input element?
If you didn't, then your condition will be false and you won't see the alert.
Ashish Mehra
2,411 PointsAshish Mehra
2,411 PointsHi Kendall McCall ,
What type of element #info is ?
Thanks,