Jump to content

[SOLVED] Required and IF, Else for radio buttons


TecTao

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
Link to comment
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!)
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.