title: Form Validation & Honeypot - Is my code right?
body: <p>I've been using the form verification below successfully so far. It has required fields, email validation and a honeypot for spam. However, one of my client is getting blank form results when really the form should not be submitted at all. So maybe I'm not seeing the obvious. It's pretty simple code I think. Can anyone take a quick look and let me know if I missed something?</p>
  
  <p>On a different note, are spam robots getting smarter than honeypots?</p>
  
  <p>This is the JS:</p>
  
  <pre><code>&lt;script&gt;
  function verify() {
      var themessage = "You are required to complete the following fields: ";
      var x=document.form.email.value
      var atpos=x.indexOf("@");
      var dotpos=x.lastIndexOf(".");
  
      if (document.form.address.value!="") {
          themessage = "You are not human! No form for you!";
      }
  
      if (document.form.first_name.value=="") {
          themessage = themessage + " - First Name";
      }
  
      if (document.form.last_name.value=="") {
          themessage = themessage + " - Last Name";
      }
  
      if (document.form.email.value=="") {
          themessage = themessage + " - E-mail";
      }
  
      if (atpos&lt;1 || dotpos&lt;atpos+2 || dotpos+2&gt;=x.length) {
          themessage = "You need to enter a valid email address";
      }
  
      //alert if fields are empty and cancel form submit
      if (themessage == "You are required to complete the following fields: ") {
          document.form.submit();
      }
  
      else {
          alert(themessage);
          return false;
      }
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>and the HTML:</p>
  
  <pre><code>&lt;form name="form" method="post" action="output.php"&gt;
      &lt;div id="input"&gt;
          &lt;div id="field"&gt;First Name:&lt;/div&gt;
          &lt;input name="first_name" type="text" id="first_name"&gt;
      &lt;/div&gt;
  
      &lt;div id="input"&gt;
          &lt;div id="field"&gt;Last Name:&lt;/div&gt;
          &lt;input name="last_name" type="text" id="last_name"&gt;
      &lt;/div&gt;
  
      &lt;div id="input"&gt;
          &lt;div id="field"&gt;Email:&lt;/div&gt;
          &lt;input name="email" type="text" id="email"&gt;
      &lt;/div&gt;
  
      &lt;div class="input address"&gt;&lt;!-- This is the Honeypot --&gt;
          &lt;div id="field"&gt;Address:&lt;/div&gt;
          &lt;input name="address" type="text" id="address"&gt;
      &lt;/div&gt;
  
      &lt;div id="input"&gt;
          &lt;div id="field"&gt;Phone:&lt;/div&gt;
          &lt;input name="phone" type="text" id="phone"&gt;
      &lt;/div&gt;
  
      &lt;div id="input"&gt;
          &lt;div id="field3"&gt;Comments:&lt;/div&gt;
          &lt;textarea name="comments" id="comments"&gt;&lt;/textarea&gt;
      &lt;/div&gt;
  
      &lt;input type="button" value="Submit" onclick="verify();"&gt;
  &lt;/form&gt;
  </code></pre>