I am creating a datacapture.cfg file, and have defined two fields as not required, but I really want to make a rule to state that if one is defined, the other must be defined too.
How can I define validation rules in teamsite for multi-part fields?
I am creating a datacapture.cfg file, and have defined two fields as not required, but I really want to make a rule to state that if one is defined, the other must be defined too.
How can I define validation rules in teamsite for multi-part fields?
Since you tagged this as XSLT, I assume that you can validate using XSLT? If so, you can do something like this:
<xsl:template match="field1[not(../field2)] | field2[not(../field1)]">
<xsl:message terminate="yes">Both fields must be defined</xsl:message>
</xsl:template>
<xsl:template match="field1 | field2">
<!-- do whatever you want to do if both are defined -->
</xsl:template>
This assumes that somewhere in your code you apply templates to those fields. Otherwise, you can also wrap this into an xsl:if
. It also assumes that those fields are XML elements, if they are attributes, change them to @field1
and @field2
and make sure you also apply templates to the attributes.