0
votes

Is there a simple way to make a Text area validation before trying to save a doc.?

I tried something like this, but still not working for me:

<xe:djTextarea id="djTextarea5" multipleTrim="true"
               multipleSeparator="#{javascript:'\n'}"
               style="width:200px;border-style:none;font-weight:bold" cols="30"
               value="#{Cdoc.nms_Responsabil}" showReadonlyAsDisabled="true">

<xe:this.validators>
        <xp:validateLength minimum="2"
        message="This field is required.">
        </xp:validateLength>
</xe:this.validators>
        <xp:eventHandler event="onChange" submit="false">
            <xe:this.script><![CDATA[
        if (document.getElementById("#{id:djTextarea5}").value) {
            document.getElementById("#{id:button1}").style.display = 'inline';
        } else {
            document.getElementById("#{id:button1}").style.display = 'none';
        }]]></xe:this.script>
        </xp:eventHandler>
</xe:djTextarea>

Thanks for your time.

2

2 Answers

1
votes

You can not use validator to validate empty value. It comes from JSF 1.2 specification: validator is not fired when value is empty. Therefore you must combine both: validator and required property.

0
votes

Validators do not trigger unless the field is also a required field. Once you add a validateRequired validator as well, it should work fine.