title: How to get my forms' Javascript error function to cancel form submission and insert error message?
body: <p>I have been reading several posts realted to this matter here on Stack Overflow and been reading the W3 Schools tutorials on Javascript and HTML forms.</p>
  
  <p>I am creating an <code>XHTML</code> form with required fields for users to submit personal data (Name, Address, Phone). I want the <code>onsubmit</code> attribute to pass each input value as an <strong>argument</strong> to my external javascript function <code>website_form_error()</code>.</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;head&gt;
     &lt;script src="http://othermindparadigm.com/web_frm_err.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;p class="mid" id="frm_responder"&gt;&amp;nbsp;&lt;/p&gt;
  
  &lt;form action="/webformmailer.php" method="post" onsubmit="javascript:website_form_error(document.getElementById('Name').value,document.getElementById('Address').value,document.getElementById('Phone').value)"&gt;
     &lt;p&gt;
        * Name &lt;input class="norm" type="text" name="Name"  /&gt;
        * Address &lt;input class="norm" type="text" name="Address"  /&gt;
        * Phone &lt;input class="norm" type="text" name="Phone"  /&gt;
     &lt;/p&gt;
  
     &lt;input type="submit"  /&gt;
  &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The form has an external JavaScript file to be called when submitted. <code>/web_frm_err.js</code></p>
  
  <pre class="lang-js prettyprint-override"><code>function website_form_error(Name,Address,Phone)
  {
      var = Name,Address,Phone,response ;
      response = (Name,Address,Phone == undefined)
         ?
         "Your specifications have been sent to Other Mind Paradigm"
         :
         "Form incomplete. You must fill in all required fields." ;
  
      document.getElementById("frm_responder").innerHTML = response ;
  }
  </code></pre>
  
  <p>I want the <code>website_form_error()</code> function to cancel the form submission and redirect back to the form and insert a message into <code>&lt;p id="frm_responder"&gt;</code> when the user has not filled in <strong>all</strong> of the required fields.
  My <code>website_form_error()</code> function does not yet have a way to cancel the submission and the text to be inserted does not trigger. I'm sure there is something wrong with my Javascript. Any answers?</p>