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 trialJonathan Leon
18,813 PointsMy form works but wont take me to 404 page, it just takes me to the form page again, is it okay?
?
4 Answers
marvelousperson206
9,199 PointsPretty sure that's cool.. happens with me too
Marlinda Davis
7,423 PointsThe same thing happened with me too.
james rochabrun
Courses Plus Student 22,726 Pointssame over here
Ziyu Zhou
739 PointsSAME
Jonathan Leon
18,813 PointsJonathan Leon
18,813 Points// Problem: Hints are shown even when forms are valid // Solution: hide and show the hints when valid var $password = $("#password"); var $confirmpassword = $("#confirm_password");
$("form span").hide();
// find out if password is valid
function isPasswordValid() {
return $password.val().length > 8 ;
}
function passwordEvent() {
if (isPasswordValid()) {
//Hide hint if valid
$password.next().hide(); } else {
//else show hint
$password.next().show(); } };
function arePasswordsMatching () {
return $password.val() === $confirmpassword.val() ; }
function confirmpasswordEvent() { // find out if password and confirmation match if (arePasswordsMatching()) { // hide hint if match $confirmpassword.next().hide(); } // else show hint else {
$confirmpassword.next().show();
}}
// when event happens on password input
$password.focus(passwordEvent).keyup(passwordEvent).focus(confirmpasswordEvent).keyup(confirmpasswordEvent).keyup(enableSubmitEvent);
// when event happens on confirmation
$confirmpassword.focus(confirmpasswordEvent).keyup(confirmpasswordEvent).keyup(enableSubmitEvent);
// if user can submit functions
function canSubmit() {
return isPasswordValid() && arePasswordsMatching();
}
// submit disable\enable
function enableSubmitEvent() {
$("#submit").prop("disabled" , !canSubmit());
}
enableSubmitEvent();