title: Set focus to field using SSJS in Xpages?
body: <p>I am validating my form using SSJS from a submit button.   To display the error to the user I am using the extension library dialog box.</p>
  
  <p>How can I set the focus to the field failing validation, using SSJS?</p>
  
  <p>One thing I might be able to do is use CSJS in the OK button of the dialog box.   I close it with the OK button as follows:</p>
  
  <pre><code>var errorField = '#{javascript:viewScope.get("errorField")}';
  </code></pre>
  
  <p>I tried the following but it does not seem to work.</p>
  
  <pre><code>if (errorField != null &amp;&amp;  errorField != "")
  {   
  var ef = document.getElementsByName("#{id:" + errorField + "}");
  ef.focus();
  
  }
  </code></pre>
  
  <p>I am setting the scope variable errorField when I  do the actual validation.</p>