cancel
Showing results for 
Search instead for 
Did you mean: 
Workflow Hero

Word count validation for multiline textbox?

Jump to solution

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

Labels: (2)
Reply
5 Replies
Workflow Hero

Re: Word count validation for multiline textbox?

Jump to solution

Hi Yvette,

I don't know if it's happened when you've pasted here the code or it's already in the code your using, but double quotes have the wrong char in your text: it should be "" instead of ” “ or “”..

if they are already in your code, could you try changing it with the proper char and test it?

Reply
Workflow Hero

Re: Word count validation for multiline textbox?

Jump to solution

That's it! Sometimes the solution can be so simple. I just hadn't noticed it. Thanks!!

One more question: how can I mark your answer as correct?  (I don't see the usual "correct answer" button)

Reply
Workflow Hero

Re: Word count validation for multiline textbox?

Jump to solution

Hi Yvette

I have converted this to a question for you - you should now see "mark correct".

Reply
Workflow Hero

Re: Word count validation for multiline textbox?

Jump to solution

Thank you!

Reply
Workflow Hero

Re: Word count validation for multiline textbox?

Jump to solution

Thanks, this works great!

Is there a way to have the numbers of words typed display in the form? Somthing like 100/500 words,  (if the limit was 500 words)?

0 Kudos
Reply