title: Check box and text field validation javascript
body: <p>I have a text field and a checkbox on a mobile website that needs to be required before submitting the form. One is a zip code search that needs to be required to go on, and also a check box for a terms and conditions.</p>
  
  <p>Right now i have the textfield validation working... </p>
  
  <pre><code>&lt;script&gt;
      function validateForm() {
          var x=document.forms["searchform"]["fromAddress"].value;
          if (x==null || x=="") {
              alert("Oops! You forgot to enter a location.");
              return false;
          }  
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>but i cant figure out how to add in the checkbox... 
  below is the code for the form:</p>
  
  <pre><code>&lt;form name="searchform" method="post" action="list.php" onsubmit="return validateForm()"&gt;
      &lt;input type="hidden" name="search" value="1" /&gt;
      &lt;input class="txtfield" type="search" id="search" name="fromAddress" onfocus="this.value=''" /&gt;
  
      &lt;div class="terms-container"&gt;
          &lt;div class="terms-checkbox-container"&gt;
              &lt;input class="acceptterms" type="checkbox" name="agree" value="agree_terms"&gt;
          &lt;/div&gt;
          &lt;div class="terms-text-container"&gt;
              I Agree to the Terms and Conditions
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;input class="btn-submit" type="submit" id="submit" value="Go!"/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>any help would be great. Thanks!</p>