spanky762
spanky762

Reputation: 171

XPages Multiline Edit Box validation fails on blank lines

I'm getting a failure when attempting to validate required content for a Multiline Edit Box control. I'm using simple required validation only, as follows:

<xp:inputTextarea
id="subject1"
rows="5"
style="width:99%"
value="${javascript:'#{compositeData.requestDocument.subject}'}"
multipleSeparator="#{javascript:@NewLine()}"
required="true">
<xp:this.validators>
    <xp:validateRequired
        message="Please explain the issue for which you need help." />
</xp:this.validators>

If I enter multiple lines WITHOUT blank lines the validation succeds:

"foo line 1 foo line 2 foo line 3"

but if I enter multiple lines WITH a blank line the validation fails:

"foo line 1

foo line 3"

Any ideas on what I'm doing wrong?

Upvotes: 0

Views: 1113

Answers (1)

spanky762
spanky762

Reputation: 171

Ok, I figured out a really simple solution myself. Don't know if this is the PROPER way to do it, but it seems to work.

I changed the validation from required to length (xp:validateRequired vs. xp:validateLength) as follows:

<xp:inputTextarea
    id="subject1"
    rows="5"
    style="width:99%"
    value="${javascript:'#{compositeData.requestDocument.subject}'}"
    multipleSeparator="#{javascript:@NewLine()}">
    <xp:this.validators>

        <xp:validateLength
            message="Please explain the issue for which you need help."
            minimum="2">
        </xp:validateLength>
    </xp:this.validators>
</xp:inputTextarea>

Upvotes: 2

Related Questions