javascript - Validate checkbox with JS -


i'm searching while , can't found works me.

this checkbox:

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

i need validate checkbox, not know i'm doing wrong. 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 function:

function validateterms(){     if(terms.val().checked(false)){         alert("error!");     } } 

why can't verify checkbox? other fields works except this. can me please?

don't check .val(), use is(":checked")

if (terms.is(":checked")) //is checked 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -