Q:

jQuery each function with if stament

I am building a function to validate forms, which I can use for upcoming projects.
The second if stament is not working, I can't figure out why.
$('.submit').click(function() {  

    var hasError = false,
        emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/,
        form = $('form'),
        radio_check = $('.tick .test'),
        input = $('input:not(.submit)'),
        emailaddressVal = $("#email").val(),
        email = $('#email');

        $('form input:not(.submit)').each(function(){
            if ($(this).val() == '') {
                $(this).css('background-color', 'red');

                if(!email.val() == '') {
                        email.css('background-color', '#faa');
                }
            }

        });
});

A:

I suppose your meaning is to check that the email field is not empty, so you should do:
if(!email.val()) { } //-> not falsey

Or
if(email.val() === '') { } //-> is empty

