Forums

Limit words in textarea

Nuvelle 06 Jan, 2015
Hi,

I am trying to limit the word count in a text area (not characters) but I can only find one post:

https://www.chronoengine.com/forums/posts/f2/t91801.html

But the link to another post in this thread does not work any more!

Are you able to help?
Nuvelle 14 Jan, 2015
Are you able to recommend a way to do it counting whole words not characters?
GreyHead 16 Jan, 2015
Answer
1 Likes
Hi Nuvelle,

Not easily, you can search around and there are some plug-ins that will try to do a word count with mixed results. It's actually quite tricky to count words accurately. The plug-ins I tried a while ago mostly seemed to split the text on spaces and that wasn't' good enough for my client. In the end we settled for a character count based on five letters per word.

Bob
Nuvelle 16 Jan, 2015
No worries, I will go back to the client and see what we can sort🙂
Nuvelle 23 Jan, 2015
Hi Bob,

I have followed the guide and attempted to put in the character limit, but as soon as I add in the JS code:

jQuery(document).ready(function (jQ) {
  jQ( '#why' ).maxlength({text: 'You have typed %length characters of %maxlength, <span style=\'color: red; font-weight:bold;\'>%left</span> remain.'});
});


All scripts on the page stop working - "parent hidden" items show, none of the red * required load etc.

I have left the page not loading properly here:
http://www.nuvelle.co.uk/cross/niche2/index.php?option=com_chronoforms5&chronoform=nominate

The box is "company insight" and is id "why" as per the code above. This box should be hidden till the person answers to see if they are the nominated person or not.

Interestingly the form works again if I cut the JS code out (and leave the file in the load event) - it just seems to be the code doesnt want to work😟
GreyHead 24 Jan, 2015
Hi Nuvelle,

I took a look but the JQuery snippet doesn't seem to be on the page you linked to.

Bob
Nuvelle 25 Jan, 2015
Sorry I had to take it off as the site went live and needed the form!


I made a copy and added the code back in:

http://www.nuvelle.co.uk/cross/niche2/index.php?option=com_chronoforms5&chronoform=nominate2
GreyHead 28 Jan, 2015
Hi Nuvelle,

I think that this must be something about the loading order. I tested your code on my test form here (the last box) and it works correctly. I see that I am loading the MaxLength file in the Load JS Files box in the Load JS action.

Bob
This topic is locked and no more replies can be posted.