Require a user to select at least one HTML checkboxWhat are valid values for the id attribute in HTML?How to align checkboxes and their labels consistently cross-browsersHow to implement “select all” check box in HTML?How can I know which radio button is selected via jQuery?How to check whether a checkbox is checked in jQuery?HTML 5: Is it <br>, <br/>, or <br />?How can I set the default value for an HTML <select> element?How to create an HTML checkbox with a clickable labelWhat's the proper value for a checked attribute of an HTML checkbox?Why does HTML think “chucknorris” is a color?

How long did it take Captain Marvel to travel to Earth?

What is more safe for browsing the web: PC or smartphone?

Picking a theme as a discovery writer

Ab major 9th chord in Bach

How to replace space with '+' symbol in a triangular array?

Convert Numbers To Emoji Math

How to say something covers all the view up to the horizon line?

My large rocket is still flipping over

Endgame puzzle: How to avoid stalemate and win?

What does のそ mean on this picture?

Was there a dinosaur-counter in the original Jurassic Park movie?

While drilling into kitchen wall, hit a wire - any advice?

Why are condenser mics so much more expensive than dynamics?

Emergency stop in plain TeX, pdfTeX, XeTeX and LuaTeX?

Can an earth elemental drag a tiny creature underground with Earth Glide?

Make me a minimum magic sum

Books of scary stories with two or three plots each

Antivirus for Ubuntu 18.04

What are the requirements for a river delta to form?

Changing stroke width vertically but not horizontally in Inkscape

Copper as an adjective to refer to something made of copper

Can anyone identify this unknown 1988 PC card from The Palantir Corporation?

How can I finally understand the confusing modal verb "мочь"?

Hostile Divisor Numbers



Require a user to select at least one HTML checkbox


What are valid values for the id attribute in HTML?How to align checkboxes and their labels consistently cross-browsersHow to implement “select all” check box in HTML?How can I know which radio button is selected via jQuery?How to check whether a checkbox is checked in jQuery?HTML 5: Is it <br>, <br/>, or <br />?How can I set the default value for an HTML <select> element?How to create an HTML checkbox with a clickable labelWhat's the proper value for a checked attribute of an HTML checkbox?Why does HTML think “chucknorris” is a color?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0


















<input type="checkbox" name="category" value="Restorative"><label for="">Restorative</label>
<br>
<input type="checkbox" name="category" value="Esthetics"><label for="">Esthetics</label>
<br>
<input type="checkbox" name="category" value="Implants"><label for="">Implants</label>





The checkboxes are all related to Sending value to the database. The user must select at least one



Restorative


Esthetics


Implants



How can I achieve this without using the select option?










share|improve this question






























    0


















    <input type="checkbox" name="category" value="Restorative"><label for="">Restorative</label>
    <br>
    <input type="checkbox" name="category" value="Esthetics"><label for="">Esthetics</label>
    <br>
    <input type="checkbox" name="category" value="Implants"><label for="">Implants</label>





    The checkboxes are all related to Sending value to the database. The user must select at least one



    Restorative


    Esthetics


    Implants



    How can I achieve this without using the select option?










    share|improve this question


























      0












      0








      0











      <input type="checkbox" name="category" value="Restorative"><label for="">Restorative</label>
      <br>
      <input type="checkbox" name="category" value="Esthetics"><label for="">Esthetics</label>
      <br>
      <input type="checkbox" name="category" value="Implants"><label for="">Implants</label>





      The checkboxes are all related to Sending value to the database. The user must select at least one



      Restorative


      Esthetics


      Implants



      How can I achieve this without using the select option?










      share|improve this question



















      <input type="checkbox" name="category" value="Restorative"><label for="">Restorative</label>
      <br>
      <input type="checkbox" name="category" value="Esthetics"><label for="">Esthetics</label>
      <br>
      <input type="checkbox" name="category" value="Implants"><label for="">Implants</label>





      The checkboxes are all related to Sending value to the database. The user must select at least one



      Restorative


      Esthetics


      Implants



      How can I achieve this without using the select option?






      <input type="checkbox" name="category" value="Restorative"><label for="">Restorative</label>
      <br>
      <input type="checkbox" name="category" value="Esthetics"><label for="">Esthetics</label>
      <br>
      <input type="checkbox" name="category" value="Implants"><label for="">Implants</label>





      <input type="checkbox" name="category" value="Restorative"><label for="">Restorative</label>
      <br>
      <input type="checkbox" name="category" value="Esthetics"><label for="">Esthetics</label>
      <br>
      <input type="checkbox" name="category" value="Implants"><label for="">Implants</label>






      html database forms






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 22 at 23:59









      Evan M

      1,9302130




      1,9302130










      asked Mar 22 at 21:58









      FrancisFrancis

      186




      186






















          2 Answers
          2






          active

          oldest

          votes


















          0














          You can cancel the submit event with event.preventDefault(). Then iterate through the checkboxes and if there is at least one of them that's checked: checkboxObj.checked then submit the form: formObj.submit(). But if there's nothing checked -- reveal an error notification.




          Demo



          Details commented in demo






          // Reference the form
          var form = document.forms[0];

          // Register the form to the submit event
          form.onsubmit = validate;

          /*
          Called on submit event...
          Prevent the form from submitting
          Reference all form controls in form
          Collect all [name=category] into an array
          Iterate through the [name=category]
          If one of them is checked submit the form
          Otherwise reveal the error notification
          */
          function validate(e)
          e.preventDefault();
          var ui = this.elements;
          var chx = Array.from(ui.category);
          for (let c of chx)
          if (c.checked)
          this.submit();


          ui.req.style.display = 'block';

          :root 
          font: 400 16px/1 Consolas


          input,
          label
          display: inline-block;
          font: inherit;
          height: 1.5rem;
          line-height: 1.5rem;
          vertical-align: middle


          [type=submit]
          float: right


          #req
          display: none;
          position: relative;
          z-index: 1;
          background: #fed;
          width: 200px;
          padding: 10px;
          bottom: 100px;
          left: 175px;
          text-align: center;

          <form id='form'>
          <fieldset>
          <input id='res' name="category" type="checkbox" value="Restorative">
          <label for="res">Restorative</label>
          <br>
          <input id='est' name="category" type="checkbox" value="Esthetics">
          <label for="est">Esthetics</label>
          <br>
          <input id='imp' name="category" type="checkbox" value="Implants">
          <label for="imp">Implants</label>
          <br>
          <input type='submit'>
          </fieldset>
          <output id='req'>Please check at least checkbox</output>
          </form>








          share|improve this answer























          • Thank you. It works.

            – Francis
            Mar 25 at 16:37











          • If this answer resolved your first question, click the checkmark ✅ of this post to accept it. As for your second question, you'll have to post a new question separate from this current question.

            – zer00ne
            Mar 26 at 0:06


















          0














          You can easily do this using JavaScript! All you need is to add an ID to the checkbox(s) you want to be required, then link it with the following JavaScript code.



          document.getElementById("myCheck").required = true;



          to be fired when the form is submitted.



          You can see more about this by clicking here.






          share|improve this answer























          • I think that will fire required on all of them. I want the option not to require all if the user selects one out of the three.

            – Francis
            Mar 22 at 22:21











          • If you add an ID to just the one you want to be required, and then select that ID with the code. Then it will only require the one. :) Don't worry, as long as you don't have duplicate ID's for multiple things, you should be fine.

            – Julian Ellis
            Mar 22 at 22:23











          • oh so that means I will skip the html required. I think I am getting it

            – Francis
            Mar 22 at 22:26











          • Precisely, simply add the code above to the function fired, and it will check if the object with the specified ID is checked, if so; It will continue--if else; it will stop.

            – Julian Ellis
            Mar 22 at 22:33











          • The downside is I think if the user does not choose one it will skip over and the form will be sent without the value from that category. What do you think?

            – Francis
            Mar 22 at 22:39











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55308318%2frequire-a-user-to-select-at-least-one-html-checkbox%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          You can cancel the submit event with event.preventDefault(). Then iterate through the checkboxes and if there is at least one of them that's checked: checkboxObj.checked then submit the form: formObj.submit(). But if there's nothing checked -- reveal an error notification.




          Demo



          Details commented in demo






          // Reference the form
          var form = document.forms[0];

          // Register the form to the submit event
          form.onsubmit = validate;

          /*
          Called on submit event...
          Prevent the form from submitting
          Reference all form controls in form
          Collect all [name=category] into an array
          Iterate through the [name=category]
          If one of them is checked submit the form
          Otherwise reveal the error notification
          */
          function validate(e)
          e.preventDefault();
          var ui = this.elements;
          var chx = Array.from(ui.category);
          for (let c of chx)
          if (c.checked)
          this.submit();


          ui.req.style.display = 'block';

          :root 
          font: 400 16px/1 Consolas


          input,
          label
          display: inline-block;
          font: inherit;
          height: 1.5rem;
          line-height: 1.5rem;
          vertical-align: middle


          [type=submit]
          float: right


          #req
          display: none;
          position: relative;
          z-index: 1;
          background: #fed;
          width: 200px;
          padding: 10px;
          bottom: 100px;
          left: 175px;
          text-align: center;

          <form id='form'>
          <fieldset>
          <input id='res' name="category" type="checkbox" value="Restorative">
          <label for="res">Restorative</label>
          <br>
          <input id='est' name="category" type="checkbox" value="Esthetics">
          <label for="est">Esthetics</label>
          <br>
          <input id='imp' name="category" type="checkbox" value="Implants">
          <label for="imp">Implants</label>
          <br>
          <input type='submit'>
          </fieldset>
          <output id='req'>Please check at least checkbox</output>
          </form>








          share|improve this answer























          • Thank you. It works.

            – Francis
            Mar 25 at 16:37











          • If this answer resolved your first question, click the checkmark ✅ of this post to accept it. As for your second question, you'll have to post a new question separate from this current question.

            – zer00ne
            Mar 26 at 0:06















          0














          You can cancel the submit event with event.preventDefault(). Then iterate through the checkboxes and if there is at least one of them that's checked: checkboxObj.checked then submit the form: formObj.submit(). But if there's nothing checked -- reveal an error notification.




          Demo



          Details commented in demo






          // Reference the form
          var form = document.forms[0];

          // Register the form to the submit event
          form.onsubmit = validate;

          /*
          Called on submit event...
          Prevent the form from submitting
          Reference all form controls in form
          Collect all [name=category] into an array
          Iterate through the [name=category]
          If one of them is checked submit the form
          Otherwise reveal the error notification
          */
          function validate(e)
          e.preventDefault();
          var ui = this.elements;
          var chx = Array.from(ui.category);
          for (let c of chx)
          if (c.checked)
          this.submit();


          ui.req.style.display = 'block';

          :root 
          font: 400 16px/1 Consolas


          input,
          label
          display: inline-block;
          font: inherit;
          height: 1.5rem;
          line-height: 1.5rem;
          vertical-align: middle


          [type=submit]
          float: right


          #req
          display: none;
          position: relative;
          z-index: 1;
          background: #fed;
          width: 200px;
          padding: 10px;
          bottom: 100px;
          left: 175px;
          text-align: center;

          <form id='form'>
          <fieldset>
          <input id='res' name="category" type="checkbox" value="Restorative">
          <label for="res">Restorative</label>
          <br>
          <input id='est' name="category" type="checkbox" value="Esthetics">
          <label for="est">Esthetics</label>
          <br>
          <input id='imp' name="category" type="checkbox" value="Implants">
          <label for="imp">Implants</label>
          <br>
          <input type='submit'>
          </fieldset>
          <output id='req'>Please check at least checkbox</output>
          </form>








          share|improve this answer























          • Thank you. It works.

            – Francis
            Mar 25 at 16:37











          • If this answer resolved your first question, click the checkmark ✅ of this post to accept it. As for your second question, you'll have to post a new question separate from this current question.

            – zer00ne
            Mar 26 at 0:06













          0












          0








          0







          You can cancel the submit event with event.preventDefault(). Then iterate through the checkboxes and if there is at least one of them that's checked: checkboxObj.checked then submit the form: formObj.submit(). But if there's nothing checked -- reveal an error notification.




          Demo



          Details commented in demo






          // Reference the form
          var form = document.forms[0];

          // Register the form to the submit event
          form.onsubmit = validate;

          /*
          Called on submit event...
          Prevent the form from submitting
          Reference all form controls in form
          Collect all [name=category] into an array
          Iterate through the [name=category]
          If one of them is checked submit the form
          Otherwise reveal the error notification
          */
          function validate(e)
          e.preventDefault();
          var ui = this.elements;
          var chx = Array.from(ui.category);
          for (let c of chx)
          if (c.checked)
          this.submit();


          ui.req.style.display = 'block';

          :root 
          font: 400 16px/1 Consolas


          input,
          label
          display: inline-block;
          font: inherit;
          height: 1.5rem;
          line-height: 1.5rem;
          vertical-align: middle


          [type=submit]
          float: right


          #req
          display: none;
          position: relative;
          z-index: 1;
          background: #fed;
          width: 200px;
          padding: 10px;
          bottom: 100px;
          left: 175px;
          text-align: center;

          <form id='form'>
          <fieldset>
          <input id='res' name="category" type="checkbox" value="Restorative">
          <label for="res">Restorative</label>
          <br>
          <input id='est' name="category" type="checkbox" value="Esthetics">
          <label for="est">Esthetics</label>
          <br>
          <input id='imp' name="category" type="checkbox" value="Implants">
          <label for="imp">Implants</label>
          <br>
          <input type='submit'>
          </fieldset>
          <output id='req'>Please check at least checkbox</output>
          </form>








          share|improve this answer













          You can cancel the submit event with event.preventDefault(). Then iterate through the checkboxes and if there is at least one of them that's checked: checkboxObj.checked then submit the form: formObj.submit(). But if there's nothing checked -- reveal an error notification.




          Demo



          Details commented in demo






          // Reference the form
          var form = document.forms[0];

          // Register the form to the submit event
          form.onsubmit = validate;

          /*
          Called on submit event...
          Prevent the form from submitting
          Reference all form controls in form
          Collect all [name=category] into an array
          Iterate through the [name=category]
          If one of them is checked submit the form
          Otherwise reveal the error notification
          */
          function validate(e)
          e.preventDefault();
          var ui = this.elements;
          var chx = Array.from(ui.category);
          for (let c of chx)
          if (c.checked)
          this.submit();


          ui.req.style.display = 'block';

          :root 
          font: 400 16px/1 Consolas


          input,
          label
          display: inline-block;
          font: inherit;
          height: 1.5rem;
          line-height: 1.5rem;
          vertical-align: middle


          [type=submit]
          float: right


          #req
          display: none;
          position: relative;
          z-index: 1;
          background: #fed;
          width: 200px;
          padding: 10px;
          bottom: 100px;
          left: 175px;
          text-align: center;

          <form id='form'>
          <fieldset>
          <input id='res' name="category" type="checkbox" value="Restorative">
          <label for="res">Restorative</label>
          <br>
          <input id='est' name="category" type="checkbox" value="Esthetics">
          <label for="est">Esthetics</label>
          <br>
          <input id='imp' name="category" type="checkbox" value="Implants">
          <label for="imp">Implants</label>
          <br>
          <input type='submit'>
          </fieldset>
          <output id='req'>Please check at least checkbox</output>
          </form>








          // Reference the form
          var form = document.forms[0];

          // Register the form to the submit event
          form.onsubmit = validate;

          /*
          Called on submit event...
          Prevent the form from submitting
          Reference all form controls in form
          Collect all [name=category] into an array
          Iterate through the [name=category]
          If one of them is checked submit the form
          Otherwise reveal the error notification
          */
          function validate(e)
          e.preventDefault();
          var ui = this.elements;
          var chx = Array.from(ui.category);
          for (let c of chx)
          if (c.checked)
          this.submit();


          ui.req.style.display = 'block';

          :root 
          font: 400 16px/1 Consolas


          input,
          label
          display: inline-block;
          font: inherit;
          height: 1.5rem;
          line-height: 1.5rem;
          vertical-align: middle


          [type=submit]
          float: right


          #req
          display: none;
          position: relative;
          z-index: 1;
          background: #fed;
          width: 200px;
          padding: 10px;
          bottom: 100px;
          left: 175px;
          text-align: center;

          <form id='form'>
          <fieldset>
          <input id='res' name="category" type="checkbox" value="Restorative">
          <label for="res">Restorative</label>
          <br>
          <input id='est' name="category" type="checkbox" value="Esthetics">
          <label for="est">Esthetics</label>
          <br>
          <input id='imp' name="category" type="checkbox" value="Implants">
          <label for="imp">Implants</label>
          <br>
          <input type='submit'>
          </fieldset>
          <output id='req'>Please check at least checkbox</output>
          </form>





          // Reference the form
          var form = document.forms[0];

          // Register the form to the submit event
          form.onsubmit = validate;

          /*
          Called on submit event...
          Prevent the form from submitting
          Reference all form controls in form
          Collect all [name=category] into an array
          Iterate through the [name=category]
          If one of them is checked submit the form
          Otherwise reveal the error notification
          */
          function validate(e)
          e.preventDefault();
          var ui = this.elements;
          var chx = Array.from(ui.category);
          for (let c of chx)
          if (c.checked)
          this.submit();


          ui.req.style.display = 'block';

          :root 
          font: 400 16px/1 Consolas


          input,
          label
          display: inline-block;
          font: inherit;
          height: 1.5rem;
          line-height: 1.5rem;
          vertical-align: middle


          [type=submit]
          float: right


          #req
          display: none;
          position: relative;
          z-index: 1;
          background: #fed;
          width: 200px;
          padding: 10px;
          bottom: 100px;
          left: 175px;
          text-align: center;

          <form id='form'>
          <fieldset>
          <input id='res' name="category" type="checkbox" value="Restorative">
          <label for="res">Restorative</label>
          <br>
          <input id='est' name="category" type="checkbox" value="Esthetics">
          <label for="est">Esthetics</label>
          <br>
          <input id='imp' name="category" type="checkbox" value="Implants">
          <label for="imp">Implants</label>
          <br>
          <input type='submit'>
          </fieldset>
          <output id='req'>Please check at least checkbox</output>
          </form>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 23 at 4:44









          zer00nezer00ne

          26.3k32547




          26.3k32547












          • Thank you. It works.

            – Francis
            Mar 25 at 16:37











          • If this answer resolved your first question, click the checkmark ✅ of this post to accept it. As for your second question, you'll have to post a new question separate from this current question.

            – zer00ne
            Mar 26 at 0:06

















          • Thank you. It works.

            – Francis
            Mar 25 at 16:37











          • If this answer resolved your first question, click the checkmark ✅ of this post to accept it. As for your second question, you'll have to post a new question separate from this current question.

            – zer00ne
            Mar 26 at 0:06
















          Thank you. It works.

          – Francis
          Mar 25 at 16:37





          Thank you. It works.

          – Francis
          Mar 25 at 16:37













          If this answer resolved your first question, click the checkmark ✅ of this post to accept it. As for your second question, you'll have to post a new question separate from this current question.

          – zer00ne
          Mar 26 at 0:06





          If this answer resolved your first question, click the checkmark ✅ of this post to accept it. As for your second question, you'll have to post a new question separate from this current question.

          – zer00ne
          Mar 26 at 0:06













          0














          You can easily do this using JavaScript! All you need is to add an ID to the checkbox(s) you want to be required, then link it with the following JavaScript code.



          document.getElementById("myCheck").required = true;



          to be fired when the form is submitted.



          You can see more about this by clicking here.






          share|improve this answer























          • I think that will fire required on all of them. I want the option not to require all if the user selects one out of the three.

            – Francis
            Mar 22 at 22:21











          • If you add an ID to just the one you want to be required, and then select that ID with the code. Then it will only require the one. :) Don't worry, as long as you don't have duplicate ID's for multiple things, you should be fine.

            – Julian Ellis
            Mar 22 at 22:23











          • oh so that means I will skip the html required. I think I am getting it

            – Francis
            Mar 22 at 22:26











          • Precisely, simply add the code above to the function fired, and it will check if the object with the specified ID is checked, if so; It will continue--if else; it will stop.

            – Julian Ellis
            Mar 22 at 22:33











          • The downside is I think if the user does not choose one it will skip over and the form will be sent without the value from that category. What do you think?

            – Francis
            Mar 22 at 22:39















          0














          You can easily do this using JavaScript! All you need is to add an ID to the checkbox(s) you want to be required, then link it with the following JavaScript code.



          document.getElementById("myCheck").required = true;



          to be fired when the form is submitted.



          You can see more about this by clicking here.






          share|improve this answer























          • I think that will fire required on all of them. I want the option not to require all if the user selects one out of the three.

            – Francis
            Mar 22 at 22:21











          • If you add an ID to just the one you want to be required, and then select that ID with the code. Then it will only require the one. :) Don't worry, as long as you don't have duplicate ID's for multiple things, you should be fine.

            – Julian Ellis
            Mar 22 at 22:23











          • oh so that means I will skip the html required. I think I am getting it

            – Francis
            Mar 22 at 22:26











          • Precisely, simply add the code above to the function fired, and it will check if the object with the specified ID is checked, if so; It will continue--if else; it will stop.

            – Julian Ellis
            Mar 22 at 22:33











          • The downside is I think if the user does not choose one it will skip over and the form will be sent without the value from that category. What do you think?

            – Francis
            Mar 22 at 22:39













          0












          0








          0







          You can easily do this using JavaScript! All you need is to add an ID to the checkbox(s) you want to be required, then link it with the following JavaScript code.



          document.getElementById("myCheck").required = true;



          to be fired when the form is submitted.



          You can see more about this by clicking here.






          share|improve this answer













          You can easily do this using JavaScript! All you need is to add an ID to the checkbox(s) you want to be required, then link it with the following JavaScript code.



          document.getElementById("myCheck").required = true;



          to be fired when the form is submitted.



          You can see more about this by clicking here.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 22 at 22:14









          Julian EllisJulian Ellis

          288




          288












          • I think that will fire required on all of them. I want the option not to require all if the user selects one out of the three.

            – Francis
            Mar 22 at 22:21











          • If you add an ID to just the one you want to be required, and then select that ID with the code. Then it will only require the one. :) Don't worry, as long as you don't have duplicate ID's for multiple things, you should be fine.

            – Julian Ellis
            Mar 22 at 22:23











          • oh so that means I will skip the html required. I think I am getting it

            – Francis
            Mar 22 at 22:26











          • Precisely, simply add the code above to the function fired, and it will check if the object with the specified ID is checked, if so; It will continue--if else; it will stop.

            – Julian Ellis
            Mar 22 at 22:33











          • The downside is I think if the user does not choose one it will skip over and the form will be sent without the value from that category. What do you think?

            – Francis
            Mar 22 at 22:39

















          • I think that will fire required on all of them. I want the option not to require all if the user selects one out of the three.

            – Francis
            Mar 22 at 22:21











          • If you add an ID to just the one you want to be required, and then select that ID with the code. Then it will only require the one. :) Don't worry, as long as you don't have duplicate ID's for multiple things, you should be fine.

            – Julian Ellis
            Mar 22 at 22:23











          • oh so that means I will skip the html required. I think I am getting it

            – Francis
            Mar 22 at 22:26











          • Precisely, simply add the code above to the function fired, and it will check if the object with the specified ID is checked, if so; It will continue--if else; it will stop.

            – Julian Ellis
            Mar 22 at 22:33











          • The downside is I think if the user does not choose one it will skip over and the form will be sent without the value from that category. What do you think?

            – Francis
            Mar 22 at 22:39
















          I think that will fire required on all of them. I want the option not to require all if the user selects one out of the three.

          – Francis
          Mar 22 at 22:21





          I think that will fire required on all of them. I want the option not to require all if the user selects one out of the three.

          – Francis
          Mar 22 at 22:21













          If you add an ID to just the one you want to be required, and then select that ID with the code. Then it will only require the one. :) Don't worry, as long as you don't have duplicate ID's for multiple things, you should be fine.

          – Julian Ellis
          Mar 22 at 22:23





          If you add an ID to just the one you want to be required, and then select that ID with the code. Then it will only require the one. :) Don't worry, as long as you don't have duplicate ID's for multiple things, you should be fine.

          – Julian Ellis
          Mar 22 at 22:23













          oh so that means I will skip the html required. I think I am getting it

          – Francis
          Mar 22 at 22:26





          oh so that means I will skip the html required. I think I am getting it

          – Francis
          Mar 22 at 22:26













          Precisely, simply add the code above to the function fired, and it will check if the object with the specified ID is checked, if so; It will continue--if else; it will stop.

          – Julian Ellis
          Mar 22 at 22:33





          Precisely, simply add the code above to the function fired, and it will check if the object with the specified ID is checked, if so; It will continue--if else; it will stop.

          – Julian Ellis
          Mar 22 at 22:33













          The downside is I think if the user does not choose one it will skip over and the form will be sent without the value from that category. What do you think?

          – Francis
          Mar 22 at 22:39





          The downside is I think if the user does not choose one it will skip over and the form will be sent without the value from that category. What do you think?

          – Francis
          Mar 22 at 22:39

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55308318%2frequire-a-user-to-select-at-least-one-html-checkbox%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript