title: Make a checkbox and check if checked
body: <p>I have a "terms of use" page, then I have the page where I have payment and such. On this page I would like the user to have to check a checkbox where it will say "if he accepts the terms of use", but I would also like a javascript, for the payment service Stripe, to check if the checkbox is checked and if not it will alert the user to check it and if it is just proceed like always.</p>
  
  <p>I have commented in the script the different functions. I want it to function so if I were to click the checkbox and then click the submit button, it will then work as usual but if I don't check the checkbox, it will then make an alert box. I would like to do this using an "if" function.
  The checkbox has to be in the form with the id "payment-form", where the rest of the inputs are.</p>
  
  <p>The javascript is the whole function in the  tags. It is the whole function that has to be disabled if the checkbox isn't checked.</p>
  
  <p>My code so far:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
  &lt;head&gt;
  
      &lt;script src="https://checkout.stripe.com/checkout.js"&gt;&lt;/script&gt;
      &lt;script src="https://code.jquery.com/jquery-1.11.2.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt; /* this is the javascript function that only has to "launch" if the checkbox is checked and if not it has to make an alert box to the user and not do any of the other functin in the javascript. */
      $(document).ready(function() {  
  
      var handler = StripeCheckout.configure({
          key: 'Removed for safety',
          image: 'image2.png',
          token: function(token) {
              var $form = $('#payment-form');
  
              $form.append($('&lt;input type="hidden" name="stripeToken" /&gt;').val(token.id));
              $form.get(0).submit();
          }
      });
  
      $('#customButton').on('click', function(e) {
  
          var amount = Math.round($("#amount").val()*100);
  
          handler.open({
          name: 'Payment',
          description: 'describtion',
          amount: amount
          });
          e.preventDefault();
      });
  
      $(window).on('popstate', function() {
          handler.close();
      });
  
  });
      &lt;/script&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
  
          &lt;div id="header"&gt;
          &lt;/div&gt;
  
          &lt;div id="container"&gt;
  
          &lt;div id="content"&gt;
  
              &lt;div class="firstproductbidwrap" style="height:500px width:800px"&gt;
  
  
                      &lt;form id="payment-form" action="chargeCard.php" method="POST" name="payment-form"&gt; &lt;!-- this is the form I would like to add the checkbox to --&gt;
                      &lt;input onkeypress="return isNumberKey(event)" type="text" name="amount" id="amount" value="" readonly/&gt;
                      &lt;input type="text" name="emailForPayment" id="emailForPayment" placeholder="Enter Email"/&gt;
                      &lt;input type="text" name="displayNameForPayment" id="displayNameForPayment" placeholder="Enter Display Name" maxlength="12"/&gt;
                      &lt;input type="image"  src="button3.png" id="customButton" value="submit" alt="button"/&gt;
                      &lt;/form&gt;
  
                      &lt;script type="text/javascript"&gt;
                      function toDec(code) {
                      return code - 48;
                      }
                      function isNumberKey(evt)
                      {
                      var charCode = (evt.which) ? evt.which : event.keyCode
                      if (charCode &gt; 31 &amp;&amp; (charCode &lt; 48 || charCode &gt; 57 || toDec(charCode) != currentVar + 1)) 
                      return false;
  
                      return true;
                      }
                      &lt;/script&gt;
  
                      &lt;script type="text/javascript"&gt;
                      var request = new XMLHttpRequest();
                      request.open('GET', 'textFileVariables.txt', false);
                      request.send();
  
                      var currentVar= parseInt(request.responseText)
                      var nextVar = currentVar + 1;
                      document.getElementById("currentVar").innerHTML = currentVar;
                      document.getElementById("nextVarDisplay").innerHTML = nextVar ;
                      document.getElementById("amount").value = nextVar ;
  
                      &lt;/script&gt;
  
  
                  &lt;div class="acceptrules"&gt;
                      When participating &lt;!-- this is the text for accept terms with the link --&gt;
                      &lt;br&gt;
                      you agree to the rules &lt;a href=""&gt;Terms of Use&lt;/a&gt;
                  &lt;/div&gt;
  
              &lt;/div&gt;
  
  
          &lt;/div&gt;
  
  
          &lt;/div&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>