liamC
Member
Registered: 28th Feb 04
User status: Offline
|
Is it possible to validate them if someone has forgot to choose one of the 3?
|
James
Member
Registered: 1st Jun 02
Location: Surrey
User status: Offline
|
Yes but I haven't done PHP for years so can't remember how.
At a guess you would need to loop through each one, set a boolean value if one has been selected and then evaluate that boolean at the end.
There might be a neater way to do it but i'm a .Net man so I couldn't tell you.
|
chumbly_warner
Premium Member
Registered: 22nd Aug 03
Location: Leicestershire
User status: Offline
|
I dont like radio buttons, i prefer to use a dropdown and then atleast you know they have selected an item...
|
PaulW
Member
Registered: 26th Jan 03
Location: Atherton, Greater Manchester
User status: Offline
|
just do a javascript function check before you pass to html, makes life easier (and quicker) for the user. also saves having to pass loads of shit back into the form from the phpscript for data already entered
|
ed
Member
Registered: 10th Sep 03
User status: Offline
|
You'd validate them in the same way as you would in any language really. You're effectively doing the same thing, just using specific expressions.
You just want to check there is a value coming from the radio buttons, so you would use something like:
code: if(!isset(radio_buttons)){
echo "You need to select an option from the radio buttons mate";
}
[Edited on 16-10-2008 by ed]
|
Sam
Moderator Premium Member
Registered: 24th Dec 99
Location: West Midlands
User status: Offline
|
Can't you just make one of them selected by default?
In the HTML output, something like:
<input type="radio" name="sex" value="male" checked="checked"> Male</input>
[Edited on 18-10-2008 by Sam]
|