View Full Version : onsubmit select one radio button only

07-30-2008, 11:53 AM
In my code i have 5 radio buttons.
I need to validate that the user should select one radio button only, during submission.If user clicks 3 radio button and give submission means,it must give me a alert message and do not submit.
I need a sample code to for my above logic.

satheesh kannan

07-30-2008, 01:21 PM
If you give all of the radios the same name, it will only let the user select one radio. :)
For example:

<input type="radio" name="food1" value="food1" /> Corn<br />
<input type="radio" name="food2" value="food2" /> Pizza<br />
<input type="radio" name="food3" value="food3" /> Steak<br />

You can select more then one. But with:

<input type="radio" name="food" value="food1" /> Corn<br />
<input type="radio" name="food" value="food2" /> Pizza<br />
<input type="radio" name="food" value="food3" /> Steak<br />

You can only select one.