kanala Posted March 20, 2008 Share Posted March 20, 2008 How would I check if a check box has been checked. The name of the form is "return" and the name of the checkbox is "agree".Is this how you do it? function checkme() {if(document.forms['return'].Agree == null){alert('Please read the policies and tick the checkbox');return false;}else{return true;}} Link to comment Share on other sites More sharing options...
Peppe L-G Posted March 20, 2008 Share Posted March 20, 2008 I'm nor sure, but until someone who knows the right answer, you can check out my gues. if(document.form_name.checkbox_name.checked == true){ //The checkbox is checked} Link to comment Share on other sites More sharing options...
zppblood Posted March 20, 2008 Share Posted March 20, 2008 <script type="text/javascript"> function checkBox(check) { if (check) { alert("Yes"); } else { alert("No"); } }</script><input type="checkbox" onclick="checkBox(this.checked)"> Link to comment Share on other sites More sharing options...
kanala Posted March 20, 2008 Author Share Posted March 20, 2008 <script type="text/javascript"> function checkBox(check) { if (check) { alert("Yes"); } else { alert("No"); } }</script><input type="checkbox" onclick="checkBox(this.checked)"> But the problem with onclick is that once you uncheck the box, it will still work. I need to know how you can find out if the box is checked. Link to comment Share on other sites More sharing options...
kanala Posted March 20, 2008 Author Share Posted March 20, 2008 But the problem with onclick is that once you uncheck the box, it will still work. I need to know how you can find out if the box is checked.Sorry but it works now, it'e because I wrote == false but it only works when you do ==false (no space).Thanks Link to comment Share on other sites More sharing options...
justsomeguy Posted March 20, 2008 Share Posted March 20, 2008 The space doesn't matter. You should use the .checked property to determine if a checkbox is checked. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.