Skip to main content

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

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?


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)


Hi Yvette

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


Thank you!


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


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


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,


 


 


 


Reply