I’m setting up a sign-up form, and user has to accept the conditions before he can submit the form. However, I haven’t found a way to succesfully validate the checkbox. It has to be checked, or the user can’t continue, and if it’s checked –> continue with the script. However, my code isn’t working as I want it to, and I’m asking for the correct way to do this.
var Ehdot = $('checkbox[name=ehdot]').is(':checked');
if((Nimi==="")||(ehdot === false)){
if(Ehdot == false){
alert('Olethan lukenut ehdot ja hyväksyt ne?');
$('checkbox[name=ehdot]').focus();
return false;
}
return false;
}
A fiddle about this: http://jsfiddle.net/utWYs/1/
If someone dares to say why I’m not using Validate plugin, I kill a kitten. 
I don’t want to use a plugin for this, as it will make the site a bit heavier and I won’t learn anything.
A small bug in your code .
There is no element named
checkboxin your dom . This will returns alwaysfalse.you have to change this line to