Checking radio buttons

K

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.
 
R

RIck Measham

kim said:
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"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,091
Messages
2,570,604
Members
47,223
Latest member
smithjens316

Latest Threads

Top