Radio Button Validation...

I have the following code to validate if a text field is filled in:

if (strlen($values['text']) == 0)
    $errors['text'] = 'sometext';

…but what I’d like to know is what code do I use to have radio buttons validated.
I have 3 buttons and a user MUST check one.

Does someone have the code for this?
Thanks in advance,
Bruce

You can validate radio buttons like this:

[php]
if (!$_POST[‘opt’])
$errors[‘text’] = ‘sometext’;
[/php]

Assuming you have the following html form:

<form method="post">
<input type="radio" name="opt" value="1"> Option 1
<input type="radio" name="opt" value="2"> Option 2
<input type="radio" name="opt" value="3"> Option 3
<input type="submit" value="Submit">
</form>

This worked perfect - Thank you! :smiley:

Sponsor our Newsletter | Privacy Policy | Terms of Service