This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Nov 24, 2011, 5:00 PM
37 Posts

Dynamic Required Field settings

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 8.5.3
  • Role: Developer
  • Tags: validator,required field
  • Replies: 2
I need to setting my text field with REQUIRED FIELD computed based in a condition with other editBox field...
 
But seem that my SSJS code don't work...
for example if my EditBox control named Subject1 the REQUIRED FIELD computed have this simple logic:
 - is required only if my other EditBox control Status1 have draft as value (the user write or choose from a List for example)
 
I try  this code:
 
var status=getComponent("status1").getValue()==null?"":getComponent("status1").getValue().toString();
status=="draft"?true:false; 
 
but don't work
 
Have you any suggest?
 
How can I resolve?
Nov 25, 2011, 5:31 AM
17 Posts
Re: Dynamic Required Field settings
try it with something like
 
var status=getComponent("status1").getValue();
if(status==null) return false;
return status=="draft"
Nov 28, 2011, 8:22 AM
261 Posts
Re: Dynamic Required Field settings
Daniele,
 
Did you look at the "disableValidators" attribute for an input control? You can use it to conditionally disable a validator.
 
Sample:
 
<xp:inputText id="inputField1">
 <xp:this.validators>
   <xp:validateRequired message="This field is required."></xp:validateRequired>
   <xp:this.disableValidators><![CDATA[#{javascript://disable validator based on another field (note: to disable return true)
 
return
    (currentDocument.getItemValueString("someOtherField")=="1" ?
        false :
        true);
}]]></xp:this.disableValidators>
</xp:inputText>

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal