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

JavaScript

Checking value cant get form to validate

I looked over my code and it seems that I have everything right need help.

Here is my code

var $submit = $(".submit input"); var $required = $(".required");

    function containsBlanks() {
        var blanks = new Array();
        $required.each(function () {
            blanks.push($(this).val() = " ");
            });
            return balnks.sort().pop();
        }

    function isValidEmail(email) {
        return email.indexOf("@") != -1;
        }

    function requiredFilledin() {
        if (containsBlanks() || !isValidEmail($("#email").val())) 
        $submit.attr("disabled", "disabled");
        else $submit.removeattr("disabled");
        }
    $("#form span").hide();
    $("input, textarea").focus (function () {
        $(this).next().fadeIn("slow");
        }).blur(function () {
            $(this).next().fadeOut("slow");
        }).keyup (function () {
        // Checks all required fields   
            });
        $("#email").keyup(function () {
            if (isValidEmail($(this).val())) 
            $(this).next().removeClass("error").addClass("valid");
            else 
            $(this).next().removeClass("valid").addClass("error");
            });
            requiredFilledin();

1 Answer

Your blanks checker has an array called "blanks", yet you return an array called "balnks" which does not exist

    // Excerpt
    blanks.push($(this).val() = " ");
    });
    return balnks.sort().pop();
}
// Excerpt