Checking radio buttons

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kim

    Checking radio buttons

    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.
  • RIck Measham

    #2
    Re: Checking radio buttons

    kim wrote:
    [color=blue]
    > 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.[/color]


    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.formn ame.pet.value=' Cat' and
    document.formna me.color.value= '') {alert('You must enter a color for your
    cat.'); return false} return true"

    Comment

    Working...