user1358852
user1358852

Reputation:

XPages - how to configure client side validation for Dojo Filtering Select controls?

I'm trying to get client side validation working with a Dojo Filtering Select, however it just does not work :-( Here is the code for the filtering select. Can anyone say what is wrong or what is missing here?

<xe:djFilteringSelect id="djFilteringSelect1">
<xe:this.dojoAttributes>
<xp:dojoAttribute name="required" value="true">
</xp:dojoAttribute>
<xp:dojoAttribute name="missingMessage" value="please add a value to this field!">
</xp:dojoAttribute>
</xe:this.dojoAttributes>
<xp:selectItem itemLabel=""></xp:selectItem>
<xp:selectItem itemLabel="Acai"></xp:selectItem>
 <xp:selectItem itemLabel="Apple"></xp:selectItem>
<xp:selectItem itemLabel="Apricot"></xp:selectItem>
<xp:selectItem itemLabel="Artichoke"></xp:selectItem>
<xp:selectItem itemLabel="Asparagus"></xp:selectItem>
<xp:selectItem itemLabel="Avocado"></xp:selectItem>
</xe:djFilteringSelect>

Upvotes: 1

Views: 380

Answers (1)

Knut Herrmann
Knut Herrmann

Reputation: 30960

If you add an empty value to the list of selectItems then this value is a valid value.

Just replace this line in your code

<xp:selectItem itemLabel=""></xp:selectItem>

with

<xe:this.defaultValue><![CDATA[""]]></xe:this.defaultValue>

then you get the missing message you expected if field is empty during submit.

Upvotes: 2

Related Questions