Skip Navigation

[Résolu] Limit Number of Allowed Words (Not Characters) in a Form Field

This support ticket is created Il y a 3 années et 7 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 2 réponses, has 2 voix.

Last updated by Ed Il y a 3 années et 7 mois.

Assisted by: Nigel.

Auteur
Publications
#1749475

Ed

I'm building a website for a classified ads company. I need to limit the number of WORDS (not characters) in a text field or text area. Is there a way to do this?

#1753645

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

Timezone: Europe/London (GMT+00:00)

Hi Ed

There isn't any such option within Toolset. In the forums you'll see people have worked on their own solutions to this over the years, though typically when limiting the field length by characters.

It's straightforward enough to count the words instead (by counting spaces), see this as an example: hidden link.

You'd need to write some jQuery/JavaScript which attaches an event listener for changes to the input field, counts the number of words, and disables the input once it reaches the limit.

I didn't come across a solution that matches your requirement for words, and as this is custom code you'll need to come up with the solution, but you should be able to find some examples to get you started in the forum.

#1753745

Ed

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.