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

Modifying Attributes

Hi There

I am sort of following along with Andrew Chalkley on the JQuery course and I am utilising his ideas on my own site.

I have an submit button with a class of submit

and I am using the following code to disable the submit button

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

    $(input).keyup(function(){
        // Check the required fields
        requiredFilledIn();
    });

    $('#email').keyup(function(){
        // This will check for a valid email

    });
    requiredFilledIn();
</script>

However it does not seem to be having any effect. Can someone tell me where I am going wrong please.

G

Take a look at your opening and closing brackets within the function.

1 Answer

Chase Lee
Chase Lee
29,275 Points

You should have curly braces around the result of each conditional.