2

Is there a way to add a character limit on node title and plain textarea fields in Drupal 8? I don't want to use the Title module.

3
  • My first guess would be hook_form_FORM_ID_alter(). Tried this one? Commented Dec 11, 2017 at 15:25
  • I was looking more for a solution that uses Javascript too, that adds character limit count and prevents input when reached. Server side validation would be second.
    – Kevin
    Commented Dec 11, 2017 at 15:26
  • Didn't use it myself yet in D8, but worked for me in D7 before: drupal.org/project/clientside_validation Commented Dec 11, 2017 at 15:30

1 Answer 1

4

There's the beta version of the Maxlength module which can be applied to built-in fields as well custom text fields. The Maxlength module allows you to set maximum length of any field; one option includes showing a javascript character countdown on the edit forms next to the applicable fields.

character countdown indicator

You could also take the js library this module is based off of and apply with the hook_form_alter approach.

1
  • 1
    This worked. I simply did not want to use the title module and have to redo a bunch of config and templates.
    – Kevin
    Commented Dec 11, 2017 at 21:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.