Display word count

Hello!
I am looking to display the number of words for a text response as people are typing in an open text box. Is there a way to do this?
Thanks!

Not directly, as far as I know.
As workaround you might count the separating blanks. You could add a variable, with a calculation and the functions: normalize(), translate() and string-length().
- With normalize() you first reduce any space duplicates in sequence.
- Then you remove all blanks using translate().
- Finally you can compare the cleaned string-length() with the original string-length().
For the functions see ODK XForms Specification.

Could you provide more details for your requirement, please?

If you want to limit the number of words, you may look at the previous discussion here How do you set word limits to text answer.

1 Like

Thank you! Ideally I would like to display the word count in the description line so that it live updates while people are typing and don’t have to guess their response length before getting the word limit error.

Would you be able to help with drafting the calculate formula?

Thanks!

Live update will not be possible (only on return / when cursor leaves the field).
Maybe someone else can help for the formula?