Jump to content

Archived

This topic is now archived and is closed to further replies.

TecTao

[SOLVED] Required and IF, Else for radio buttons

Recommended Posts

I'm having a real problem writing part of a form that has three radio buttons to select a method of payment.

The three radio buttons are the same name "pay" so that only one can be clicked.

Second, they are required so one out of the three must be clicked to submit.

Third, each radio button has a small text field to put, number attending, amount of check or phone number.

What I need help on is to if one button isn't clicked, then the next or then next but one of the three must be required.

thanks for any help
m

Share this post


Link to post
Share on other sites
You don't need any script for this. Simply have one of the radio buttons selected by default.

<input type="radio" name="pay" id="pay" value="1" selected="selected">Number Attending
<input type="radio" name="pay" id="pay" value="2">Cheque Amount
<input type="radio" name="pay" id="pay" value="3">Phone Nummber

(Odd for radio buttons as tehy don't seem connected - but hey its your form!)

Share this post


Link to post
Share on other sites
Thanks for the input, but having the viewer select on of the buttons isn't the challenge. Each radio button has a corresponding text box to fill in something. One of those boxes must be required along with the radio button selection.

So if the pick the first button "number attending" then they have to fill in the corresponding text field.
If the select "Check Amount" then they have to fill in that corresponding text field.
and the same for the last.

None of the radio buttons are selected so they have to select one and fill in the text field info.

Currently I'm using a java script to require text fields, but since I haven't been able to write or locate a java script for radio button selections, I'm considering the required field option using a php if else statement.

Share this post


Link to post
Share on other sites
You cant do it with php unless the text box will appear in the next screen.
You will nee JS for this one. Use the onFocus and onBlur to do this.

Orio.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.