I'm facing an issue related to additional validation for my field. I have 2 fields in form, User and Replacement (for this user). User has default value of current user, and I want to validate if User selected for the Replacement is the same User that in the User field. Also, Replacement can't be empty.
I've added validateRequired for this field and it works fine when the client side validation is on, it displays alert with message.
For checking values I've set validateExpression and set for expression code like below:
<xp:validateExpression message="Test">
<xp:this.expression><![CDATA[#{javascript:var user = document1.getItemValueString("User")
if (value == user) {
return false
}
return true}]]>
</xp:this.expression>
</xp:validateExpression>
The problem is, that even if values are properly validated, this doesn't display any information related to validation. It is stopping submitting form but nothing else happens.
Is it correct to use validateExpression for this kind of validation? I checked also customValidator but it didn't work at all.
Did you add one of the necessary error display controls? They are
<xp:messages id="messages1"></xp:messages>
<xp:message id="message1"></xp:message>
And you need them to display the error message in a convenient place.
See also: https://help.hcl-software.com/dom_designer/9.0.1/user/wpd_controls_cref_messages.html