Javascript: how to bring focus to an element, and show a warning message
<p>Preface, I really don't know javascript at all.</p>

<p>I am trying to validate the email address of a form.  If validation fails, I would like to focus on the invalid email field, and show a warning message.  The below code properly returns true or false if the "focusElement" line is removed.  However, it always returns true with that line included (presumably because the line is invalid and the code does not execute.  Is there a proper/simple way of focusing on this element and showing the message?</p>

<pre><code>function validateForm(formElement) 
  {
    var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;  
    if(emailPattern.test(formElement.tfEmail.value))
    {
        return true;
    }
    else
    {
        focusElement(formElement.tfEmail,'Please enter a valid e-mail address.');
        return false;
    }
  }
</code></pre>
