title: set focus to textbox form element following Validation
body: <p>I have a number of fields on a form that I perform Validation on, which I then want to Focus on if the validation fails. The Validation works fine, i.e. rtnStr, but the focus() just won't land on any of the textbox fields, i.e. vCtrl. It remains on the Submit button.</p>
  
  <pre><code>&lt;script language="javascript"&gt;
  
  function ValidateForm() {
      var rtnStr = "";
      var vCtrl = "";
  
      //Contact Details //
      if (document.contactform.txtforename.value == "") {
          rtnStr = rtnStr + " - Please enter your Forename.\n"
          if (vCtrl == "") {
              vCtrl = "txtforename";
          }
      }
  
      if (document.contactform.txtSurname.value == "") {
          rtnStr = rtnStr + " - Please enter your Surname.\n"
          if (vCtrl == "") {
              vCtrl = "txtSurname";
          }
      }
  
      if (rtnStr != "") {
          alert(rtnStr)
          window.setTimeout(function () {
              document.getElementById(vCtrl).focus();
          }, 0);
          return false;
      }
      else {
          return true;
      }
  }               
  &lt;/script&gt;
  </code></pre>