Skip to main content
Nintex Community Menu Bar

Word count validation for multiline textbox?

  • March 7, 2017
  • 7 replies
  • 37 views

Forum|alt.badge.img+7

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

7 replies

Forum|alt.badge.img+11
  • Nintex Partner
  • March 7, 2017

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?


Forum|alt.badge.img+7
  • Author
  • March 7, 2017

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? happy.png (I don't see the usual "correct answer" button)


Forum|alt.badge.img+16

Hi Yvette

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


Forum|alt.badge.img+7
  • Author
  • March 8, 2017

Thank you!


Forum|alt.badge.img+2
  • September 27, 2018

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)?


Forum|alt.badge.img+2
  • August 5, 2019

Thanks, this works great!

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


Forum|alt.badge.img+1

Hi @yvette  and @jackgelo 

 

I am new to using Javascript with Nintex for SP2013 and I was wondering if you could help me out with this. In your code here where does it reference the javascript variable which i want this function to apply to? Lets say I have a multi line textbox called 'projsumm'. Where do I reference 'projsumm' in your javascript code? if I even reference it directly at all? I am looking to apply a maximum limit of 250 words to be used in a textbox

 

Any help would be greatly appreciated.

 

Cheers,