validators - Validators List
Enforces requirements for data entry.
Category
dataSyntax
<xp:this.validators>
validator ...
</xp:this.validators>
Where validator
is
one of the following:<xp:validateLength attributes>content</xp:validateLength>
<xp:validateRequired attributes>content</xp:validateRequired>
Usage
In Design mode, click the Validation tab under Properties, or click All Properties and look for validators under data.Contained properties
Validators have the following properties which can be static or computed.Header | Header |
---|---|
Where n is
an integer greater than minimum . |
(validateLength ) The
maximum number of characters that a user can enter for string input. |
|
(validateLength , validateRequired )
The text of a message returned to the user when validation fails. |
|
(validateLength ) The
minimum number of characters that a user can enter for string input. |
Examples
This Edit Box control is required.<xp:inputText id="inputText1" value="#{document1.subject}"
required="true">
<xp:this.validators>
<xp:validateRequired message="Subject is required"></xp:validateRequired>
</xp:this.validators>
</xp:inputText>
This Edit Box has minimum and maximum
lengths.
<xp:inputText id="inputText1" value="#{document1.subject}">
<xp:this.validators>
<xp:validateLength minimum="1" maximum="8">
<xp:this.message>
<![CDATA[#{javascript:return "Invalid: " + this.validators.value}]]>
</xp:this.message>
</xp:validateLength>
</xp:this.validators>
</xp:inputText>
This Edit Box is required and
has a maximum length.
<xp:inputText id="inputText1" value="#{document1.subject}"
required="true">
<xp:this.validators>
<xp:validateLength maximum="64"
message="Subject cannot exceed 64 characters">
</xp:validateLength>
<xp:validateRequired message="Subject is required"></xp:validateRequired>
</xp:this.validators>
</xp:inputText>