The constraint-valid() function

Smartsite 7.2 - ...

The constraint-valid() function returns a boolean indicating whether or not the specified node is valid, taking only the constraint into account (if any). 

XML CopyCode image Copy Code
string exf:constraint-valid(node)

This extension function is particularly useful when you want to supply different alert messages to the user, dependent on the reason why a field is not valid (wrong input, no input when the field is required, duplicate entry, etc.)

Example:

XML CopyCode image Copy Code
<xf:bind nodeset="instance('res')/code_duplicate" relevant="not(exf:constraint-valid(instance()/cms:entry/cms:code))" />

Within the above example, the code_duplicate node within the 'res' instance (which contains an alert message that the specified code is not valid according to constraint restrictions) is set to relevant when the code field within the default instance does not conform to it's constraint restriction(s).

Namespaces

This function is available within the Smartsite XForms namespace (http://smartsite.nl/namespaces/xforms/1.0).