title: Javascript form validation: how to force focus to remain on 'incorrect' field?
body: <p>I can't believe that I can't find the answer to this question but I really have searched and can't find it! honest!</p>
  
  <p>anyway - here is the question: I am trying to create a validation function for a form that will not permit the user to proceed to the next form field if the field doesn't validate. 
  I just want the 'incorrect' field to have focus until it is 'correct'.</p>
  
  <p>because this is for a JS class I cannot use jQuery or any other framework.</p>
  
  <p>here is one of the HTML fields:</p>
  
  <pre><code>&lt;li&gt;Number 1:&lt;input class="field2" type="text" id="star1" onchange="validateAndDraw(this.value);"&gt;&lt;/li&gt;
  </code></pre>
  
  <p>and here is a truncated version of the JS function:</p>
  
  <pre><code>function validateAndDraw(theValue) {                
    if (isNaN(theValue)) {
      alert("no good");
    } else {
        [do stuff here]
    }
  }
  </code></pre>
  
  <p>I have tried using 'this.focus();' and 'this.parentNode.focus();' but no joy. </p>
  
  <p>I am sure the answer is ridiculously simple, but I can't seem to find it. </p>
  
  <p>thanks,
  bennett</p>