title: form validation with javascript to php
body: <p>I find this code in W3Schools. It's about form validation with Javascript.</p>
  
  <p>When the user tape wrong mail format, an alert is appear.</p>
  
  <p>When I check the code I see on form <code>onsubmit="return validateForm();</code>, well the function return false in error case.</p>
  
  <p>So my question is how to get the boolean value from javascript to use it in PHP to write error message instead of use of message box.</p>
  
  <p>This is my code:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;script type="text/javascript"&gt;
      function validateForm()
      {
      var x=document.forms["myForm"]["email"].value
      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;/head&gt;
  
      &lt;body&gt;
      &lt;form name="myForm" action="demo_form.asp" onsubmit="return validateForm();" method="post"&gt;
      Email: &lt;input type="text" name="email"&gt;
      &lt;input type="submit" value="Submit"&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>Thanks in advance.</p>
  
  <p>Ali</p>