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
Anas AlHariri
8,776 PointsWhy the console giving me an error with val?!
Why the console giving me an error with val?!
It says that Uncaught TypeError: this.val is not a function(…)
Here is my code :
//Problem: Hints are shown even when form is valid.
//Solution: Hide and show them at appropriate times
//hide hints.
$("form span").hide();
//when event happens on passwords input (.Change()) or (.focus()).
$("#password").focus(function(){
//Find out if the password is valid.
if ((this).val().length > 8){
//hide hints if valid.
$(this).next("span").hide();
}else {
//else show hints.
$(this).next("span").show();
}
});
//When event happens on confimation input
//Find out if password and confirmation match.
//hide hint if match
//else
//show the hint
1 Answer
Anas AlHariri
8,776 PointsOh!! I found the problem. I missed typing $ before this in the code of if((this).val().length > 8){}
It suppose to be as the following
if($(this).val().length > 8 ){
}