cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Nintex Newbie

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
7 Replies
Highlighted
Automation Master
Automation Master

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?

View solution in original post

Reply
Highlighted
Nintex Newbie

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
Highlighted
Automation Master
Automation Master

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
Highlighted
Nintex Newbie

Re: Word count validation for multiline textbox?

Jump to solution

Thank you!

Reply
Highlighted
Nintex Newbie

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
Highlighted
Nintex Newbie

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? Something like 100/500 words,  (if the limit was 500 words)?

0 Kudos
Reply
Highlighted
Nintex Newbie

Re: Word count validation for multiline textbox?

Jump to solution

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,

 

 

 

0 Kudos
Reply