I would like to have a Required Validator on a field but it will be required based on another field’s value.
How can I do this?
If I use Custom Validator, there is no way to put a message for the error. ( or I can’t find it )
I only get
xp:this.validators
xp:customValidator
xp:this.validate
</xp:this.validate>
</xp:customValidator>
</xp:this.validators>
Where does the message go?
Subject: Try expressionValidator
Have you try instead of a customValidator a expressionValidator.See the example.
<xp:inputText id=“inputTest” value=“#{currentDocument.Test}” required=“true”>
<xp:this.validators>
<xp:validateRequired
message="Please enter a value">
</xp:validateRequired>
<xp:validateExpression
message="Please enter the word 'TEST'">
<xp:this.expression><![CDATA[#{javascript:var strValue:string = getComponent("inputTest").getSubmittedValue();
if( strValue == "TEST" )
return true;
else
return false;}]]>
</xp:this.expression>
</xp:validateExpression>
</xp:this.validators>
</xp:inputText>