Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
VFE text area text length validation
System
We want to be able to limit the maximum "text" (excluding html tags) entered into a VFE enabled text area to be 250. Does any one have any suggestions? I'm thinking of using formAPI, but how would I strip off all the html tags from the string I get from IWItem.getValue()? Is it possible to leverage any api in eweteditpro?
Find more posts tagged with
Comments
jbonifaci
Get the value, use a regex to remove all html tags, then check the length of the string.
~Jeff
Migrateduser
I thought about regex, too. Will something like <(.|\n)*?> be good enough for all html tags?
jbonifaci
Well, all you really need is .replace(/<.*?>/sg,""), which will treat the string as a single line and . will include new lines. Now, this will still leave any additional whitespace around your tags, so you might also want to do something like .replace(/(\s)\s*/sg, "$1"), which will leave single white space characters and replace multiple white space characters with a single character. This should get you closer to the character count you are looking for. Unless of course you don't want to include whitespace in your count at all, in which case you could remove all whitespace.
~Jeff
Migrateduser
Thanks, Jeff!