title: form not validating - javascript
body: <p>bit of a noob with form validation.  I'm trying to get this form to validate on the required fields, and something's amiss.  Here's what I'm working with:</p>
  
  <p>html:</p>
  
  <pre><code>&lt;form action="../visit/thankyou.html" method="post" id="vsurvey"&gt;
      &lt;input type="hidden" name="id" value="503" /&gt;
      &lt;fieldset&gt;
          &lt;legend&gt;Group and Coordinator Information&lt;/legend&gt;
          &lt;label&gt;&lt;span&gt;Group Leader Name&lt;span style="color:#cc2d30"&gt;*&lt;/span&gt;&lt;/span&gt;
              &lt;input type="text" name="question_8149" /&gt;
          &lt;/label&gt;
          &lt;label&gt;&lt;span&gt;Email&lt;span style="color:#cc2d30"&gt;*&lt;/span&gt;&lt;/span&gt;
              &lt;input type="text" name="question_8155" /&gt;
          &lt;/label&gt;
          &lt;label&gt;&lt;span&gt;Phone&lt;span style="color:#cc2d30"&gt;*&lt;/span&gt;&lt;/span&gt;
              &lt;input type="text" name="question_8156" /&gt;
          &lt;/label&gt;
          &lt;label&gt;&lt;span&gt;School/Organization&lt;span style="color:#cc2d30"&gt;*&lt;/span&gt;&lt;/span&gt;
              &lt;input type="text" name="question_8159" /&gt;
          &lt;/label&gt;
          &lt;label&gt;&lt;span&gt;Program&lt;/span&gt;
              &lt;input type="text" name="question_8180" /&gt;
          &lt;/label&gt;
          &lt;label&gt;&lt;span&gt;Grade(s)&lt;/span&gt;
              &lt;input type="text" name="question_8181" /&gt;
          &lt;/label&gt;
          &lt;label&gt;&lt;span&gt;Number of Participants&lt;span style="color:#cc2d30"&gt;*&lt;/span&gt;&lt;/span&gt;
              &lt;input type="text" name="question_8182" /&gt;
          &lt;/label&gt;
      &lt;/fieldset&gt;
      &lt;fieldset&gt;
          &lt;label&gt;&lt;span&gt;Preferred Date&lt;span style="color:#cc2d30"&gt;*&lt;/span&gt;&lt;/span&gt;
              &lt;input class="date" type="text" id="question_8185" name="question_8185" /&gt;
          &lt;/label&gt;
          &lt;label&gt;&lt;span&gt;Second Preference Date&lt;span style="color:#cc2d30"&gt;*&lt;/span&gt;&lt;/span&gt;
              &lt;input class="date" type="text" id="question_8186" name="question_8186" /&gt;
          &lt;/label&gt;
          &lt;label&gt;&lt;span&gt;Third Preference Date&lt;span style="color:#cc2d30"&gt;*&lt;/span&gt;&lt;/span&gt;
              &lt;input class="date" type="text" id="question_8187" name="question_8187" /&gt;
          &lt;/label&gt;
          &lt;label&gt;Special Accommodations
              &lt;input type="text" name="question_8174" /&gt;
          &lt;/label&gt;
      &lt;/fieldset&gt;
      &lt;label&gt;What is the purpose or desired outcome of this visit?
          &lt;textarea name="question_13026"&gt;&lt;/textarea&gt;
      &lt;/label&gt;
      &lt;label&gt;How did you learn about our Group Visit Program?
          &lt;textarea name="question_8176"&gt;&lt;/textarea&gt;
      &lt;/label&gt;
      &lt;label&gt;Comments
          &lt;textarea name="question_8184"&gt;&lt;/textarea&gt;
      &lt;/label&gt;
      &lt;input type="submit" id="sbutton" value="Submit Request" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>js:</p>
  
  <pre><code>function validateForm() {
      var x = document.forms["vsurvey"]["question_8149"].value;
      if (x == null || x == "") {
          alert("Please fill in the Group Leader's name.");
          return false;
      }
  
      var x = document.forms["vsurvey"]["question_8155"].value;
      if (x == null || x == "") {
          alert("Please fill in the email field.");
          return false;
      }
  
      var x = document.forms["vsurvey"]["question_8156"].value;
      if (x == null || x == "") {
          alert("Please fill in the phone field.");
          return false;
      }
  
      var x = document.forms["vsurvey"]["question_8159"].value;
      if (x == null || x == "") {
          alert("Please fill in the School/Organization field.");
          return false;
      }
  
      var x = document.forms["vsurvey"]["question_8182"].value;
      if (x == null || x == "") {
          alert("Please indicate the number or participants.");
          return false;
      }
  
      var x = document.forms["vsurvey"]["question_8185"].value;
      if (x == null || x == "") {
          alert("Please enter your preferred date.");
          return false;
      }
  
      var x = document.forms["vsurvey"]["question_8186"].value;
      if (x == null || x == "") {
          alert("Please enter your second date preference.");
          return false;
      }
  
      var x = document.forms["vsurvey"]["question_8187"].value;
      if (x == null || x == "") {
          alert("Please enter your third date preference.");
          return false;
      }
  }
  </code></pre>
  
  <p><a href="http://jsfiddle.net/blackessej/9a6BJ/1/" rel="nofollow">http://jsfiddle.net/blackessej/9a6BJ/1/</a></p>
  
  <p>Currently the form submits the info anyway, but without sending the user to the thankyou page, if all required fields aren't filed in.  If all required fields are filed, the thankyou page gets called.</p>