Saltar navegación

[Resuelto] Limit Number of Allowed Words (Not Characters) in a Form Field

This support ticket is created hace 4 años, 9 meses. 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.

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+01:00)

Este tema contiene 2 respuestas, tiene 2 mensajes.

Última actualización por Ed hace 4 años, 9 meses.

Asistido por: Nigel.

Autor
Mensajes
#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
Colaborador

Idiomas: Inglés (English ) Español (Español )

Zona horaria: Europe/London (GMT+01: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: enlace oculto.

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!