title: xpages validation on field having onChange script
body: <p>There is a <code>required</code> field:</p>
  
  <pre><code> &lt;xp:this.validators&gt;
                              &lt;xp:validateRequired
                                  message="Required field. Please add some text."&gt;
                              &lt;/xp:validateRequired&gt;
   &lt;/xp:this.validators&gt;
  </code></pre>
  
  <p>Also, the value from this field is copied ( using the <code>onChange</code> event ) to other fields:</p>
  
  <pre><code>     &lt;xp:eventHandler event="onchange" submit="true"refreshMode="norefresh"&gt;
            &lt;xp:this.action&gt;&lt;![CDATA[#{javascript:Cdoc.setValue("dlg_Localitate",Cdoc.getValue("txt_LocalitateCompanie"));
          Cdoc.setValue("dlg_Localitate_1",Cdoc.getValue("txt_LocalitateCompanie"))}]]&gt;                                                                                   
           &lt;/xp:this.action&gt;
     &lt;/xp:eventHandler&gt;
  </code></pre>
  
  <p>An inconvenient issue appears when I just click the field to fill it: the validation message appears. Is because the field initially is empty and the code I added is into the onChange event?</p>
  
  <p>I'd like to use this field as required before users can save the doc.</p>
  
  <p>I tried set the values by CSJS, but without a result...</p>
  
  <pre><code>var string = XSP.getElementById("#{id:inputText1}").value
  XSP.getElementById("#{id:txt_LocalitateS}").value = string
  XSP.getElementById("#{id:txt_LocalitateP}").value = string
  </code></pre>
  
  <p>Also, let say I enter a value for <code>inputText1</code> and later on I enter a new value... How can I update automatically the other 2 fields with the new value?</p>
  
  <p>I tried something like this:</p>
  
  <pre><code>&lt;xp:inputText id="inputText1" value="#{Cdoc.txt_LocalitateCompanie}"
                          style="height:20.0px;width:122.0px;font-weight:bold;font-size:10pt;font-family:verdana"
                          required="true"&gt;
  
  
                          &lt;xp:this.validators&gt;
                              &lt;xp:validateRequired message="Completarea localitatii este obligatorie."&gt;
                              &lt;/xp:validateRequired&gt;
                          &lt;/xp:this.validators&gt;
                          &lt;xp:typeAhead mode="full" minChars="1" ignoreCase="true"
                              id="typeAhead1"&gt;
                              &lt;xp:this.valueList&gt;&lt;![CDATA[#{javascript:@DbLookup(@DbName(),"vwLocalitati",Cdoc.txt_LocalitateCompanie,1,"[PARTIALMATCH]");}]]&gt;&lt;/xp:this.valueList&gt;
                          &lt;/xp:typeAhead&gt;
                          &lt;xp:eventHandler event="onchange" submit="true"
                              refreshMode="norefresh"&gt;
                              &lt;xp:this.action&gt;&lt;![CDATA[#{javascript:Cdoc.setValue("dlg_Localitate",Cdoc.getValue("txt_LocalitateCompanie"));
  Cdoc.setValue("dlg_Localitate_1",Cdoc.getValue("txt_LocalitateCompanie"))}]]&gt;&lt;/xp:this.action&gt;
  
                              &lt;xp:this.script&gt;&lt;![CDATA[XSP.partialRefreshGet("#{id:txt_LocalitateS}", {
      onComplete: function() {
          XSP.partialRefreshGet("#{id:txt_LocalitateP}", {
              onComplete: function(){ } 
          });
      }
  });]]&gt;&lt;/xp:this.script&gt;
                          &lt;/xp:eventHandler&gt;
                      &lt;/xp:inputText&gt;
  </code></pre>
  
  <p>Thanks in advance</p>