title: Javascript validation focus
body: <p>I am writing a validation script for an HTML form.  The script makes a list of errors appear at the top of the document, so that the user can see (and correct) them all at once.  I'd like the focus to move to that error list when the document reloads after the validation script runs, but this isn't working, and heaven help me I can't see why.  Any tips would be very much appreciated.  Thank you!</p>
  
  <p>Here is the JS</p>
  
  <pre><code>function validate(survey) {
      var error=document.createElement("text");
      error.innerHTML=" ";
  
      var x=document.survey.member_email.value;
      if (x==null || x=="")  {
          error.innerHTML+="&lt;li&gt;Please enter an email address&lt;/li&gt;" 
          var vp=document.getElementById("validate_place");
          vp.appendChild(error);
          vp.focus( );      //  Here is the focus command   --&gt;//
          return false;
          } 
      return true;
  }
  </code></pre>
  
  <p>And here are the validation lines in HTML:</p>
  
  <pre><code>&lt;form action="survey_processing.php" method="post"  onsubmit="return validate(this);"  name="survey" id="survey" &gt;
  
  &lt;div id="validate_place" &gt; &lt;/div&gt;  &lt;!--- empty div to insert validation correction info if needed --&gt;
  </code></pre>