API
@-Formulas
JavaScript
LotusScript
Reg Exp
Web Design
Notes Client
XPages
 
Validating a ComboBox Control
I have a combo box control where I wanted to make sure the user selected something. By default, the first choice in the combo box is the default choice. Which makes validation pretty useless (there's something selected). But if you make a blank entry the first entry, then you can do something.

First, add a computed value as the first choice. The computed value should return an empty string. In the source, this is what it will look like:

<xp:comboBox id="Option1" value="#{doc.Option1}">
<xp:selectItems>
    <xp:this.value><![CDATA[#{javascript:return "";}]]></xp:this.value>
</xp:selectItems>

After that will be the rest of your entries - either hard-coded, or from a formula, or both.

Once you have the first item being an empty string, you can add a simple "validate required" entry using the All Properties panel. Find the "validators" section and add a "validate required" entry and enter your message. In the source, it will look like this:

    </xp:selectItems>
    <xp:this.validators>
        <xp:validateRequired message="Please choose an option from the list">
        </xp:validateRequired>
    </xp:this.validators>
</xp:comboBox>

That's it. Pretty easy.