Something like this would work, and it’s a very simple script.
http://lab.artlung.com/validate-checkbox/
Does that help?
Hi that looks like it should work, although I am not sure how to apply this to my php file for the comments in my wordpress…?
You just need to change the target’s name…
Take this example element.
<input type="CHECKBOX" name="CHECKBOX_1" value="This...">
In this case the target name is CHECKBOX_1
which is then reflected in the Javascript.
You just need to find out the name (name="example"
) for your checkbox and update the Javascript to reflect that.
You’ll need to place the Javascript in between the <head>
tags in your header.php
Here’s an example (you’d need to change where i’ve put “NAME-HERE”)
<script type="text/javascript" language="JavaScript">
<!--
function checkCheckBoxes(theForm) {
if (
theForm.NAME-HERE.checked == false)
{
alert ('You didn\'t choose any of the checkboxes!');
return false;
} else {
return true;
}
}
//-->
</script>
And also add onsubmit="return checkCheckBoxes(this);"
onto the comments form.. (comments.php in your theme – same file you’ve proberly added your checkbox to).
It’s untested, but it should be that easy (i can’t see why not)….
🙂
Thank you so much for your reply! It took me a little while to get it sorted because I forgot to put onsubmit=”return checkCheckBoxes(this);” in the comments form! But now it is working a dream! 🙂 🙂
I hope other people find this post and use the info in it! Thanks a lot t31os_
Ben
http://www.koha.biz/wordpress/ check out an article too see 🙂 Site still work in progress