Hello,
There are a couple ways of doing this, some being with client side validation, and server side... And of course both!
To check to see if they've "checked" the checkbox by either $_POST, or $_GET you need to do the following:
Lets say in this example we've got the form, with the input field checkbox, and name of it as chkAgreeExample:
Code:
<form....>
<input type="checkbox" name="chkAgreeExample" />
</form...
Now when the form is submitted, and you want the server side validation to pick it up do the following in PHP: This example I'm using $_POST superglobal, if you're submitting the form using $_GET use that instead of where I've written $_POST.
PHP Code:
if(isset($_POST))
{
/// other checks....
#Lets check just for this option..
if($_POST["chkAgreeExample"] == "ON")
{
# do magic here...
}
///.... blah blah blah
}
Now if you want to have a client side validation, you can capture the value of it by doing the following:
Code:
var checkBox = document.getElementById("YourIdOfCheckBoxHERE");
checkBoxValue = checkBox.value;
You can also use the jQuery library by doing this:
Code:
$(document).ready(function(){
if ($('#edit-checkbox-id:checked').val() !== null) {
// Insert code here.
}
});
Hope this helps,
Shaun