5 Replies Latest reply: Apr 11, 2012 3:16 PM by peppemonkey RSS

    Link 2 radio button

    yeungyam Community Member

      I have a form where if one radio button1 is clicked, radio button2 becomes mandatory. It could also be the opposite, if radio button2 is clicked, then radio button1 becomes mandatory. None of them can also be left blank.

        • 1. Re: Link 2 radio button
          whyisthisme Community Member

          In the layoutReady event of the first radiobuttonlist you put (in formcalc):

           

          if ($.isNull == 0 and RadioButtonList2.isNull) then

              RadioButtonList2.validate.nullTest = "error"

          else

              RadioButtonList2.validate.nullTest = "disabled"

          endif

           

          and then you would do the same for the second radiobuttonlist just renaming the lists.

          • 2. Re: Link 2 radio button
            yeungyam Community Member

            Thanks for your answer, but I put the code in and nothing happens!

            It doesn't prompt for RadioButtonList2 and I can still submit the form.

            • 3. Re: Link 2 radio button
              Jenn Andrews

              Radio Buttons are special group of objects.  If your radio button 1 and radio button 2 are in the "same" RadioButtonList then they are set to be a mutually exclusive group therefore one on one off.  Both on and off are valid answers for a RadioButton therefore if set to be required only 1 button is required to be 'on'

              This is likely why you can still submit as off is a valid answer as long as one button in the RadioButtonList is 'on'

               

              For a solution, I would suggest ensuring that your radio buttons are in different RadioButtonLists therefore they are not mutually exclusive group and each would have to be on if it was required.

              • 4. Re: Link 2 radio button
                yeungyam Community Member

                They are in two different RadioButtonList. There is RadioButtonList1 and RadioButtonList2; and there is a checkbox. If checkbox is clicked, everything is fine and that's it. However, if something is clicked in RadioButtonList1, then RadioButtonList2 becomes mandatory, or vice versa... if any of RadioButtonList2 is clicked, then RadioButtonList1 becomes mandatory.

                • 5. Re: Link 2 radio button
                  peppemonkey

                  add a Textfield, delete the caption and make it invisible.  Then put this on the calculate event:

                   

                  If (RadioButtonList1.rawValue + RadioButtonList2.rawValue >= "1") then

                  RadioButtonList1.mandatory = "error"

                  RadioButtonList2.mandatory = "error"

                  endif

                   

                  the vales of the radio buttons have to be numeric for this to work though.