View Full Version : Tick box to go next

03-09-2010, 09:17 AM
Hello Guys,

I have a oscommerce store, for which i want to be able to make sure that if the tick box is not ticked then it will not go to the next page, so for example.

customer clicks on finish to order, but gets a popup saying please tick the box, and if ticked, the page just goes normal

THank you

03-09-2010, 10:30 AM
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:


<input type="checkbox" name="chkAgreeExample" />


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.

/// 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:

var checkBox = document.getElementById("YourIdOfCheckBoxHERE");
checkBoxValue = checkBox.value;

You can also use the jQuery library by doing this:

if ($('#edit-checkbox-id:checked').val() !== null) {
// Insert code here.

Hope this helps,