During my development I crossed a requirement to do a mandatory check for a Richtext field binded with a XPage's Rich Text element. In that XPage I have implemented most of the validations from the server side code where my project also needs that too. So I need to do Richtext mandatory validation in XPages using SSJS.
Here we go. The following code helps me to do that. I hope there no need of explanation for this snippet.
Hope this helps.
Here we go. The following code helps me to do that. I hope there no need of explanation for this snippet.
var BodyText = @Trim(getComponent("body").getValue());
var RegEx = /(<([^>]+)>)| /ig
BodyText = BodyText.replace(RegEx,"")
if(@Trim(BodyText) == "" )
{
//Through Mandatory Error Message here
}
Hope this helps.
No comments:
Post a Comment