By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,932 Members | 1,529 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,932 IT Pros & Developers. It's quick & easy.

Checking radio buttons

P: n/a
kim
I'm trying to check my radio buttons before the form is submitted.
The radio button names are the same(pend) because only one should be
selected. I also would like to know how to make sure if a radio
button has been selected, a text box the on form has to be completed
before the form is submitted. In other words if the Cat radio button
is selected then the user has to enter data in the color text box
before the form will be submitted.
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
kim wrote:
I'm trying to check my radio buttons before the form is submitted.
The radio button names are the same(pend) because only one should be
selected. I also would like to know how to make sure if a radio
button has been selected, a text box the on form has to be completed
before the form is submitted. In other words if the Cat radio button
is selected then the user has to enter data in the color text box
before the form will be submitted.

Given the name of your form is 'formname' and the radio group is 'pet' and
the color textbox is 'color' then insert the following into your form
declaration:

onSubmit="if (document.formname.pet.value='Cat' and
document.formname.color.value='') {alert('You must enter a color for your
cat.'); return false} return true"
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.