PDA

View Full Version : checkform checkbox woes



marynorn
04-16-2008, 10:56 AM
I have a checkbox on my registration form for people to tick that they've read the terms and conditions. If they don't check it they get an error message, and if they do check it the forms submits.

If I use the following code:

function checkForm(form)
{
if(!form.tandc.checked) {
alert("Please confirm that you have read the Terms & Conditions");
}
return false;
}
I get the popup, but the once the box is checked the form won't submit. If I take out the 'return false' the page submits as soon as you hit the OK button on the popup.

I suspect I have to put in an else conditional, but I haven't the faintest idea what it should be. Javascript is really not my thing.

And while I'm here... I need to add another bit to that checkform so the password field matches the confirm password field. I'm lost on this one. I have a snippet of code, but it's obviously missing something:

if(form.passwod.value != "" && form.password.value == form.pwdcheck.value) {
alert("Your password does not match the confirmation password")
}

Nile
04-16-2008, 11:42 AM
I don't believe that using javascript in this situation is good, I think that you should use PHP, not all browsers, and people support javascript.

marynorn
04-16-2008, 12:01 PM
I don't believe that using javascript in this situation is good, I think that you should use PHP, not all browsers, and people support javascript.
Yes, I'd probably prefer to do it that way, and the site is php so very doable. The problems is that I know even less about php than I do about javascript, and the deadline for the form is close of business tomorrow. If you can point me at a good php tutorial, I'd be grateful.

Nile
04-16-2008, 08:37 PM
Here, this tutorial taught me:
http://tizag.com/phpT