The required-valid() function

Smartsite 7.2 - ...

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

XML CopyCode image Copy Code
string exf:required-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_required" relevant="not(exf:required-valid(instance()/cms:entry/cms:code))" />

Within the above example, the code_required node within the 'res' instance (which contains an alert message that the specified code is not valid because it is required but the node does not contain a value) is set to relevant when the code field within the default instance does not conform to it's required restriction(s).

Namespaces

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