Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Build an Interactive Website Form Validation and Manipulation Modifying Attributes

Nthulane Makgato
Nthulane Makgato
Courses Plus Student 19,602 Points

Modifying Attributes in JQuery video

I have just watched a video on modifying attributes but there are certain lines of code that I don't understand.

                    var $submit = $(".submit input");
        function requiredFilledIn(){
            if(true) $submit.attr("disabled","disabled");
            else $submit.removeAttr("disabled");

                    $("#form span").hide();
            //Check all required fields.

             //check for a valid email.
             if(false) $(this).next().removeClass("error")addClass("valid");
             else $(this).next().removeClass("valid").addClass("error");


So the if/else statements in the requiredFilledIn function determine whether the ".submit input" is submitted but they are determined by whether there are inputs in the ".submit input" fields. My question is, how does the "requiredFilledIn()" know that the input fields are empty or filled?

I hope that the extract of code that I gave you is enough. Thanks for your help.