drupaltextfieldcharacterwordslimits

Drupal textfield input limiting


My client wants to limit the input into a textfield to 16 words - I have no idea how to achieve this.

In addition, he wants to disble characters from being part of the input. In other words, allow only 16 words and with no special characters.

Can anyone give me some ideas?


Solution

  • This is an unusual use case and in a quick search I don't see that there is a module that provides these particular limits for a Drupal 7 field. I think you will need to write a custom module which adds a field widget where you can set limits for number of words and allowed characters (well, making this configurable would make a much more useful module that could be re-used and shared). You could use Regex in your validation function. Javascript / jQuery could be used to dynamically check the word count, use of allowed characters and/or character count limits for the field.

    If you don't know how to write such a module, you can describe your requirements on any of the several sites which exist for hiring freelancers and get a quote for the work... then ideally make the module "community contributed".