When a user clicks a radio button on - how do I make the next few fields required?
Sorry for the long title...
I have an add me to your newsletter radio button. The next few fields are for address information. If they check the add me radio button I want the next few fields required.
How do I do that?
Thanks!!!!
andy206uk posted this at 02:27 — 23rd December 2006.
He has: 1,758 posts
Joined: Jul 2002
You could use javascript conditionals, or verify the users input in the script that processes the form.
For instance in PHP you could do something like:
<?php
if($_POST[radiobutton] == \"blah\") {
if(!$_POST[input1]) { $error .= \"you have not entered input 1<br />\";
if(!$_POST[input2]) { $error .= \"you have not entered input 2<br />\";
}
if($error) {
echo(\"<p>$error</p>\");
} else {
//**** process form
}
?>
Andy
Brooke posted this at 13:55 — 4th January 2007.
She has: 681 posts
Joined: Feb 1999
Sorry that I didn't get back to you sooner...I don't know php at all...what do I ddo with it? Where does it go? What you wrote - i that everythiing that I need?
Thanks!!
andy206uk posted this at 18:45 — 4th January 2007.
He has: 1,758 posts
Joined: Jul 2002
It's not designed to be implemented. It's just a code sample - you'll need to learn a bit of PHP before you can do it. Basically you can't do what you want without knowing one type of scripting language or another...
Andy
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.