0

I'm searching a while for this and i can't found something that works for me.

This is my checkbox:

<input type="checkbox" class="main_account_form_checkbox" id="terms" name="terms" />

I need validate this checkbox, but do not know what I'm doing wrong. This is the steps in js file I'm working on:

Field: var terms = $('#terms');

On blur: terms.blur(validateTerms);

Checking:

form.submit(function(){
    if(validateTerms())
        return true
    else
        return false;
});

And the function:

function validateTerms(){
    if(terms.val().checked(false)){
        alert("Error!");
    }
}

Why I can't verify the checkbox? All other fields works except this. Can anyone help me please?

0

2 Answers 2

5

Don't check the .val(), just use is(":checked")

if (terms.is(":checked")) //is checked
Sign up to request clarification or add additional context in comments.

Comments

1

Use checked property.

So to see if not checked

if(!terms.checked){
    alert("Error!");
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.