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
Post a Comment