validatorRequired
is required additionally, but alone does not help.
If the user clicks on the RichText field and does not enter anything, the content gets the value
<p dir="ltr"> </p>
and the test for an empty value no longer works.
So, we have to fix this with a replacement () before we check for ".".
<xp:messages id="messages1" /> <xp:inputRichText value="#{document1.Request}" id="inputRichText1" style="width:99.0%" disableClientSideValidation="true"> <xp:this.validators> <xp:validateExpression message="Attachment is missing"> <xp:this.expression><![CDATA[#{javascript: var text = (value + " ").replace(/(<((?!img|a\s)[^>]+)>)| /ig, "").trim(); return text !== ""; }]]></xp:this.expression> </xp:validateExpression> <xp:validateRequired message="Attachment is missing" /> </xp:this.validators> </xp:inputRichText>
Regular expression excludes all html <...>
and
except for image tags <img...>
and link tags <a <a...>
.
source share