Sylvain Wallez wrote:

Hi all,

I encountered a problem today: I have a form where a field is required or not depending on the value of another field. I wanted to control this using the validation (with a <wd:assert>) but couldn't as the validators aren't called if the value is null.


I currently use a work around:

<wd:field id="firstName">
<wd:datatype base="string">
<wd:validation>
<wd:assert test="Or(IsNull(firstName), Not(IsNull(dateOfBirth)))">
<wd:failmessage><i18n:text>dateofbirth.required</i18n:text></wd:failmessage>
</wd:assert>
</wd:validation>
</wd:datatype>
</wd:field>


<wd:field id="dateOfBirth">
<wd:datatype base="date">
<wd:convertor>
<wd:patterns>
<wd:pattern>dd/MM/yyyy</wd:pattern>
</wd:patterns>
</wd:convertor>
<wd:validation>
<wd:assert test="Or(IsNull(firstName), Not(IsNull(dateOfBirth)))">
<wd:failmessage><i18n:text>dateofbirth.required</i18n:text></wd:failmessage>
</wd:assert>
</wd:validation>
</wd:datatype>
</wd:field>


This makes dateOfBirth required only when firstName is not null.

Vadim


Reply via email to