How do you set word limits on an excepted text answer; i.e., prevent the responder from typing in more than 500 words, for example.
Thank you in advance.
How do you set word limits on an excepted text answer; i.e., prevent the responder from typing in more than 500 words, for example.
Thank you in advance.
@cokoro, you should be able to do it as outlined in our support article Restricting Text Responses With Regular Expressions:
hi, i am trying to set word limits of 175 words, 350, and 650 for text answers - i used "regex(., ‘^\W*\w+\b\W*){175}$’) but it creates an error - does not allow me to put anything
Welcome back to the community, @anupah! Do you mean you are trying to limit the words to 175
, or are you trying to limit the word to 175
or 350
or 650
?
Thanks Kal - i have different word limits for different questions - i tried using the regex from the 3 word example but I can’t quite get it right ( my experience with regex and coding is very limited)
The W and w, relates to characters, not to complete words, as all regex expressions.
Could you provide more details, please:
Workarounds: You may count separators between words like blancs/spaces. And you might try if string-length function works on a whole multi-word text field, see https://getodk.github.io/xforms-spec/#fn:string-length.
Thank you!! - I used this finally : regex(., ‘^\W*(\w+\b\W*){0,550}$’) and it works well - for ex. to et a limit of 550 words