We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22770
    • 285 Posts
    I have multiple checkboxes and I want to ensure that at least one of them is checked when the form is submitted. Here is the code I have:

    <p><input type="checkbox" name="registrationFee[]" value="Full 2-day package: £275" id="fullRegistrationFee" eform="Registration Fee::1"/> <label for="fullRegistrationFee"  class="checkboxlabel">Full 2-day package: <strong>£275</strong></label></p>
    
    <p><input type="checkbox" name="registrationFee[]" value="Subsidised 2-day package: £200" id="subsidisedRegistrationFee" /><label for="subsidisedRegistrationFee"  class="checkboxlabel">Subsidised 2-day package for students, no affiliation or third sector: <strong>£200</strong></label></p>
    
    <p><input type="checkbox" name="registrationFee[]" value="1 day - 8th July only: £100" id="8JulyRegistrationFee" /><label for="8JulyRegistrationFee"  class="checkboxlabel">1 day - 8<sup>th</sup> July only: <strong>£100</strong></label></p>
    
    <p><input type="checkbox" name="registrationFee[]" value="1 day - 9th July only: £100" id="9JulyRegistationFee" /><label for="9JulyRegistrationFee"  class="checkboxlabel">1 day - 9<sup>th</sup> July only: <strong>£100</strong></label></p>


    If, to check the validation, I submit the form with none of the boxes checked, it rejects it. However, it only highlights the first three checkboxes as being required. The source code this produces is:

    <p><input type="checkbox" name="registrationFee[]" id="fullRegistrationFee" class="required" value="Full 2-day package: £275"  /><label for="fullRegistrationFee" class="checkboxlabel required">Full 2-day package: <strong>£275</strong></label></p>
    
    <p><input type="checkbox" name="registrationFee[]" id="subsidisedRegistrationFee" class="required" value="Subsidised 2-day package: £200"  /><label for="subsidisedRegistrationFee" class="checkboxlabel required">Subsidised 2-day package for students, no affiliation or third sector: <strong>£200</strong></label></p>
    
    <p><input type="checkbox" name="registrationFee[]" id="8JulyRegistrationFee" class="required" value="1 day - 8th July only: £100"  /><label for="8JulyRegistrationFee" class="checkboxlabel required">1 day - 8<sup>th</sup> July only: <strong>£100</strong></label></p>
    
    <p><input type="checkbox" name="registrationFee[]" id="9JulyRegistationFee" class="required" value="1 day - 9th July only: £100"  /><label for="9JulyRegistrationFee" class="checkboxlabel">1 day - 9<sup>th</sup> July only: <strong>£100</strong></label></p>
    


    As you can see, the class "required" isn’t appended to the label in final item, although it is to the checkbox itself.

    Also, and even more worryingly, if I do check one of the boxes, the validation message says: "Registration Fee » Incorrect value". huh

    Can anyone spot what I’m doing wrong? grin
      • 30223
      • 1,010 Posts
      typo...
      <input .... id="9JulyRegistationFee" />
      <label for="9JulyRegistrationFee" ...>
        • 22770
        • 285 Posts
        Quote from: TobyL at Jan 19, 2009, 11:07 AM

        typo...
        <input .... id="9JulyRegistationFee" />
        <label for="9JulyRegistrationFee" ...>
        Ha. cool And to think I read that so many times... Thank you.

        That fixes the highlighting issue, but I’m still getting the "Incorrect value" error when I do check one of the boxes. Any ideas on that one?
          • 22770
          • 285 Posts
          Okay, if I remove the validation entirely from the checkboxes, I still get an ’Incorrect value’ error. Am I doing something wrong with the multiple checkboxes? Something in the values themselves?

          Here’s the code at the moment:

          <p><input type="checkbox" name="registrationFee[]" value="Full 2-day package: £275" id="fullRegistrationFee" /><label for="fullRegistrationFee"  class="checkboxlabel">Full 2-day package: <strong>£275</strong></label></p>
          
          <p><input type="checkbox" name="registrationFee[]" value="Subsidised 2-day package: £200" id="subsidisedRegistrationFee" /><label for="subsidisedRegistrationFee"  class="checkboxlabel">Subsidised 2-day package for students, no affiliation or third sector: <strong>£200</strong></label></p>
          
          <p><input type="checkbox" name="registrationFee[]" value="1 day - 8th July only: £100" id="8JulyRegistrationFee" /><label for="8JulyRegistrationFee"  class="checkboxlabel">1 day - 8<sup>th</sup> July only: <strong>£100</strong></label></p>
          
          <p><input type="checkbox" name="registrationFee[]" value="1 day - 9th July only: £100" id="9JulyRegistrationFee" /><label for="9JulyRegistrationFee"  class="checkboxlabel">1 day - 9<sup>th</sup> July only: <strong>£100</strong></label></p>


          embarrassed
            • 22770
            • 285 Posts
            Okay, just talking to myself here... grin

            The problem appears to be with the &pound; entity in the value. All works fine when that’s deleted. Is this an eForm bug or is &pound; invalid in that context?
              • 30223
              • 1,010 Posts
              I’m not sure about that one. When I’ve got time and when my laptop is repaired (which just lost it’s fan and is overheating) I’ll do some testing maybe.
                • 20413
                • 2,877 Posts
                Maybe stupid suggestion... Try &amp;pound;
                  @hawproductions | http://mrhaw.com/

                  Infograph: MODX Advanced Install in 7 steps:
                  http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                  Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                  http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower