• Resolved mslovak

    (@mslovak)


    I’ve had a request from to limit the number of words that can be entered in a given text box on a form. I know that this is a difficult construct but was wondering if anyone has come up with a solution for this in cforms. Basically I would want to enforce something like a 50 word limit for a textarea field. Character limits won’t work. Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author bgermann

    (@bgermann)

    You would use regular expressions for this. Something like ^.{0,50}$

    • This reply was modified 5 years, 6 months ago by bgermann.
    Thread Starter mslovak

    (@mslovak)

    Thank you for your response and suggestion. I tried this:

    Presenter Bio for Brochure (50 words or less)|Enter no more than 50 words|^\W*(?:\w+\b\W*){1,50}$|err:Enter no more than 50 words

    Which seemed to work perfectly. When I entered more than 50 words it gave me my error. When I entered less than 50 words it passed and posted.

    However there seems to be a problem. The data in the field is not posted. I only get blanks even when there are fewer than 50 words.

    I first entered 60 words, got an error, reduced it to 40 which posted but I received no text in the field. I next simply entered 10 words and posted but received no text in the field. All other fields post their data so it seems as if when there is a regx that the data isn’t posted, unless I am doing something else wrong. The text above is exactly what is in the field definition.

    Thanks in advance for any help.
    Marc

    Plugin Author bgermann

    (@bgermann)

    Your RegEx works fine for me on cformsII 14.14 and PHP 7.2.11.

    • This reply was modified 5 years, 6 months ago by bgermann.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Words count limits in text box’ is closed to new replies.