5 Replies Latest reply on Jun 20, 2008 9:34 AM by

    Checkbox Validation

    Ads901 Level 1
      Hi All

      I have got the following code - which is part of a form and what I want it to do is validate so that the user can only select one of teh boxs - but it isnt working. If you select one it wont submit the form.

      Can some tell me how this should be correctly structured please and end my misery!

      <td class="Form_Headings">Would you like to recieve future email updates?</td>
      <td><label><span id="spryEmailUpdates">
      <input type="checkbox" name="Email Updates Yes" id="EmailUpdatesYes">
      <span class="Typestyle_body">Yes</span><span class="Typestyle_body">
      <input name="input" type="checkbox" value="">
      No</span> <span class="checkboxRequiredMsg">Please make a selection.</span></span></label></td>
        • 1. Re: Checkbox Validation
          Level 7
          .oO(Ads901)

          > I have got the following code - which is part of a form and what I want it to
          >do is validate so that the user can only select one of teh boxs

          Use radio buttons.

          >- but it isnt
          >working. If you select one it wont submit the form.
          >
          > Can some tell me how this should be correctly structured please and end my
          >misery!
          >
          > <td class="Form_Headings">Would you like to recieve future email updates?</td>
          > <td><label><span id="spryEmailUpdates">
          > <input type="checkbox" name="Email Updates Yes" id="EmailUpdatesYes">
          > <span class="Typestyle_body">Yes</span><span class="Typestyle_body">
          > <input name="input" type="checkbox" value="">
          > No</span> <span class="checkboxRequiredMsg">Please make a
          >selection.</span></span></label></td>

          The 'label' element is not used properly and control names should not
          contain spaces. A simple example:

          <td>
          <label><input type="radio"
          name="EmailUpdates" value="1"> Yes</label>
          <label><input type="radio"
          name="EmailUpdates" value="0" checked="checked"> No</label>
          <p>Please make a selection.</p>
          </td>

          Micha
          • 2. Re: Checkbox Validation
            Level 7
            On Thu, 12 Jun 2008 15:18:41 +0200, Michael Fesser <netizen@gmx.de>
            wrote:

            >The 'label' element is not used properly and control names should not
            >contain spaces. A simple example:

            Additionally, if your desire is as you stated, "the user can only
            select one of teh boxs," you should be using radio buttons instead of
            checkboxes.

            Gary
            • 3. Re: Checkbox Validation
              Level 7
              .oO(Gary White)

              >On Thu, 12 Jun 2008 15:18:41 +0200, Michael Fesser <netizen@gmx.de>
              >wrote:
              >
              >>The 'label' element is not used properly and control names should not
              >>contain spaces. A simple example:
              >
              >Additionally, if your desire is as you stated, "the user can only
              >select one of teh boxs," you should be using radio buttons instead of
              >checkboxes.

              I've already said that at the beginning, just a bit shorter. ;-)

              But it's OK to repeat, since it's an important thing in order to make
              the form more userfriendly. Checkboxes always indicate the possibility
              of multiple choices or none at all, while radio buttons clearly say
              "pick just one". An interesting reading about this:

              Checkboxes vs. Radio Buttons
              http://www.useit.com/alertbox/20040927.html

              Micha
              • 4. Re: Checkbox Validation
                Level 7
                On Thu, 12 Jun 2008 18:57:37 +0200, Michael Fesser <netizen@gmx.de>
                wrote:

                >I've already said that at the beginning, just a bit shorter. ;-)

                Oops! I see that now. I had missed it before.


                >Checkboxes vs. Radio Buttons
                > http://www.useit.com/alertbox/20040927.html

                That's a worthwhile read for way too many people. ;-)

                Gary
                • 5. Re: Checkbox Validation
                  Thank you for your sample code it was usefull in another case