user2028856
user2028856

Reputation: 3183

jQuery test if form fields aren't empty

I know this might sound like a basic question but I have the following code to test that a form's fields aren't empty:

$('.button_overlay').mouseover(function() {
    if ($.trim($("#field1").val()) != "" && $.trim($("#field2").val()) != "") {
        $('.button_overlay').css('display', 'none');
    }
 });

But I keep getting a "Uncaught SyntaxError: Unexpected token ILLEGAL" error. I'm not sure why this isn't valid though. Anyone able to give some pointers?

Thanks

Upvotes: 0

Views: 88

Answers (1)

user2028856
user2028856

Reputation: 3183

Okay I really couldn't find what the issue was so I just created a nested if statement within the main if statement. This achieves the same effect as the &&.

Upvotes: 1

Related Questions