Sunday, 15 May 2011

Xpages Rich Text validation -



Xpages Rich Text validation -

is there way validate rich text add together validateexpression doesn't work.

thanks

<xp:inputrichtext value="#{document1.request}" id="inputrichtext1" style="width:99.0%"> <xp:this.validators> <xp:validateexpression message="attachment missing"> <xp:this.expression><![cdata[#{javascript: if(getcomponent("inputrichtext1").getsubmittedvalue()!== ''){ homecoming true }}]]></xp:this.expression> </xp:validateexpression> </xp:this.validators></xp:inputrichtext>

the validatorrequired required in add-on doesn't help on own.

if user clicks richtext field , doesn't input it's content gets set to

<p dir="ltr"> &nbsp;</p>

and test empty value doesn't work anymore.

so, have eliminate replace() before test "".

class="lang-xml prettyprint-override"><xp:messages id="messages1" /> <xp:inputrichtext value="#{document1.request}" id="inputrichtext1" style="width:99.0%" disableclientsidevalidation="true"> <xp:this.validators> <xp:validateexpression message="attachment missing"> <xp:this.expression><![cdata[#{javascript: var text = (value + " ").replace(/(<((?!img|a\s)[^>]+)>)|&nbsp;/ig, "").trim(); homecoming text !== ""; }]]></xp:this.expression> </xp:validateexpression> <xp:validaterequired message="attachment missing" /> </xp:this.validators> </xp:inputrichtext>

the regular look eliminates html tags <...> , &nbsp; except image tags <img...> , link tags <a...>.

validation xpages

No comments:

Post a Comment