move you window redirecting code to a javascript function. Make your onclick call a function to validate the checkbox (again, in javascript), and then if the checkbox is checked you can then redirect.
Actually looking at your code, you seem to be mixing 2 approaches. You do not actually need the onclick if you set the input type to "submit" and the form action to "nflStats.html". Using this will trigger your confirmSubmit function too.
So there are 2 approaches you can take, I suggest you take the latter one I have mentioned.
sillyboy
Practically a Master Poster
686 posts since Mar 2007
Reputation Points: 85
Solved Threads: 64
Watch your blocks as I think you are missing a few { }.
I would do it slightly different to you, but this is how I would do it:
function confirmSubmit() {
var acc = document.getElementById("accept");
if (!acc.checked) {
alert("You must agree with the above items in order to utilize the statistics form.");
return false;
} else {
return true;
}
}
For this to work with your code, just make sure you set the id for your checkbox to "accept".
sillyboy
Practically a Master Poster
686 posts since Mar 2007
Reputation Points: 85
Solved Threads: 64
var acc = document.getElementById('accept') assigns the reference of the checkbox element of your form to acc. Checkboxes have a property checked which determines whether a checkbox is checked or not.
Thus !acc.checked means 'when checkbox is not checked'.
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734