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.
-
My first guess would be hook_form_FORM_ID_alter(). Tried this one?– Mario SteinitzCommented 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.– KevinCommented 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– Mario SteinitzCommented Dec 11, 2017 at 15:30
Add a comment
|
1 Answer
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.
You could also take the js library this module is based off of and apply with the hook_form_alter
approach.
-
1This worked. I simply did not want to use the title module and have to redo a bunch of config and templates.– KevinCommented Dec 11, 2017 at 21:13