AnsweredAssumed Answered

Word count validation for multiline textbox?

Question asked by yvette on Mar 7, 2017
Latest reply on Sep 27, 2018 by robeadie

In my form at least 20 words should be used to describe the reason for a request. I can't use a regex for a multine textbox, so I have googled for some javascript and found this great post by @Dan Stoll. However, I can't make the following code work:

 

function wordCount(source, args) {

var words = args.Value.split(” “);
words = NWF$.grep(words, function (element, index) {
if (element.trim() != “”) {
return true;
}
});
if (words.length < 20)
{
args.IsValid = false;
}
}

 

I also don't see anything on saving the client id of the textbox control in a javascript variable (value?). Does anyone have any suggestions?

 

Kind regards,
Yvette

Outcomes