title: simpleCart(js) Adding form input validation to email checkout submit
body: <p>I've added a validation to the form which produces a window stating the field is empty, the problem is that it is still submitting the form even though it has returned false on the invalid fields.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function validateForm(){
  var x=document.forms["form"]["name"].value;
  if (x==null || x=="")
    {
    alert("First name must be filled out");
    return false;
    }
  var atpos=x.indexOf("@");
  var dotpos=x.lastIndexOf(".");
  if (atpos&lt;1 || dotpos&lt;atpos+2 || dotpos+2&gt;=x.length)
    {
    alert("Not a valid e-mail address");
    return false;
    }
  }
  &lt;/script&gt;
  
  
  &lt;form action="sendjs.php"  name="form" &gt;
                  &lt;em&gt;&lt;strong&gt;Fill in the fields below BEFORE pressing checkout.&lt;/strong&gt;&lt;/em&gt;&lt;br /&gt;
                    &lt;input placeholder="Name" type="text" name="name"  value="" id="name" title="Please enter a name!" /&gt;
                    &lt;input placeholder="Phone Number" type="text" name="phone" value="" id="phone" /&gt;
                    &lt;input placeholder="Email" type="text" name="email" value="" id="email"title="Please enter an email!" /&gt;
           &lt;input type="submit"  onclick="return validateForm();" class="simpleCart_checkout" value="Checkout"/&gt;
                  &lt;/form&gt;
  </code></pre>
  
  <p>Here is the simpleCart.js</p>
  
  <pre><code>me.emailCheckout = function kiwi() {    
  
  itemsString = "";
  for( var current in me.items ){ 
      var item = me.items[current];
      itemsString += item.name + " " + item.quantity + " " + item.price + "\n";
  }   
  
  name = document.form.name.value;
  phone = document.form.phone.value;
  email = document.form.email.value;
  
  
  var form = document.createElement("form");
  form.style.display = "none";
  form.method = "POST";
  form.action = "sendjs.php";
  form.acceptCharset = "utf-8";
  form.appendChild(me.createHiddenElement("jcitems", itemsString));
  form.appendChild(me.createHiddenElement("jctotal", me.total));
  form.appendChild(me.createHiddenElement("name", name));
  form.appendChild(me.createHiddenElement("phone", phone));
  form.appendChild(me.createHiddenElement("email", email));
  document.body.appendChild(form);    
  form.submit();
  document.form.submit();
  document.body.removeChild(form);
  }
  </code></pre>