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 trialTrent Burkenpas
22,388 PointsI broke my JQuery :(
So I was following along in the video, but right about when we gave ("#password") a var name of $password. My JQuery stopped working. Here is my code!
//Problem: Hints are shown even when form is valid
//Solution: Hide and show them at appropriate times
var $password = $("#password");
var $confirmPassword = $("#confirm_password");
//Hide hints
$("form span").hide();
function passwordEvent(){
//Find out if password is valid
if($password.val().length > 8) {
//Hide hint if valid
$password.next().hide();
} else {
//else show hint
$password.next().show();
}
}
function confirmPasswordEvent () {
//find out if password and confirmation match
if($password.val() === $confirmPassword.val()) {
//Hide hint if match
$confirmPassword.next().hide();
} else {
//else Show hint
$confirmPassword.next().show();
}
//When event happens on password input
$("#password").focus(passwordEvent).keyup(passwordEvent);
//when ebent happens on confirmation input
$("#confirm_password").fcus(confirmPasswordEvent).keyup(confirmPasswordEvent);
3 Answers
Andrew Shook
31,709 PointsTrent check you console log for errors you will probably see something along the lines of "... has not method fcus". You have a typo on this line:
$("#confirm_password").fcus(confirmPasswordEvent).keyup(confirmPasswordEvent);
it should be focus.
In the future you can undo the changes you've made to the file one by one and save the file. Reload the page until it starts working again. When its start working again redo the change and that's your bug. Also your confirmPasswordEvent function is missing it's closing '}".
Trent Burkenpas
22,388 PointsOk I See, but it still didn't fix the problem. When I type a password longer then 8 characters the element that tells you to make a password longer then 8 doesn't go away. I fact it always showing, even before I click on the text input box. Ill check my console log
Andrew Shook
31,709 PointsJust edited my last post. You forgot the closing "}" on you confirmPasswordEvent function.
Trent Burkenpas
22,388 Pointsyep that did the trick. Thank you!