I'm creating a module using clientside validation to limit the number of words a user can type into a particular textarea. I'm using the maxwords method added by clientside_validation.js. However, since that method (along with minwords and rangewords) use value.split(' ').length to count the number of words, if a user enters multiple spaces between words (as, for example, some people do at the end of a sentence) then this method will miscount the number of words by including several "empty" words corresponding to each extra space.

I'll attach a patch which uses a regular expression (/\s+/) to give the correct result.

Comments

dyule’s picture

Attached is a patch to correctly validate word count

jelle_s’s picture

Status: Active » Fixed

fixed in the latest dev version. Thanks for the patch!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.