This does work:
currentDocument.isEditable() && getComponent("djTextarea1").value
You don't have to test !=""
. If you just test for a value in JavaScript it returns false
if value is null
or ""
and otherwise true
. In your case it is important to test for null too.
.value
is fine. You don't have to get the value with .getValue()
.
In case your component "djTextarea1" is connected to document's field you should use the field instead the component in your code like
currentDocument.isEditable() && document1.getValue("fieldname")
Update:
The best solution in your case is to use CSJS as you want to show button as soon as a value is entered in "djTextarea5". Here is the code you need:
<xe:djTextarea
id="djTextarea5"
value="#{frmDoc.txt_names}">
<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>
<xp:button
value="Do something with djTextarea"
id="button1">
<xp:this.style><![CDATA[#{javascript:
currentDocument.isEditable() && frmDoc.getValue("txt_names") ?
"display:inline" :
"display:none"
}]]></xp:this.style>
</xp:button>