I think what's going wrong is that you seem to be embedding a form within a form (stored as a PHP variable
This does not look good and could well be causing unexpected behaviour.
Also your mark-up is rather convoluted and you really shouldn't be using tables for layout purposes.
Unfortunately, I couldn't actually reproduce your error.
If I substituted ##TERMS## for the content of
$terms, then nothing worked at all.
If I just added a checkbox with an id of "tos" then everything worked as expected.
So, where does this leave you?
To give you an idea of how this should be done properly, consider the following code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Form checkbox example</title>
<form action="myscript.php" method="post" id="myForm">
<label for="accountNo">Bank account number:</label>
<input type="text" id="accountNo" name="accountNo" />
<label for="terms">I accept the terms and conditions.</label>
<input type="checkbox" id="terms" name="terms" />
<input type="submit" value="Submit" />
f = document.getElementById("myForm");
alert("Please accept the terms and conditions first!");
This will work in all browsers.
If you're unsure of how to implement this and would like further help, then go to the page with your form on, view the page's source code, then copy and paste the complete source code here (please use code tags).
Then at least I will be able to see your exact markup and in so doing remove PHP from the equation.
If you would like some help to move your form away from a table-based layout, then I'll also be glad to help.