Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem
By default, the textarea field is assigned the maxlength attribute. maxlength.js accounts for html tags by regexing them and removing them from the character count, but this is still constrained by the maxlength attribute on the textarea element.
E.g.
<textarea maxlength="300"> ..etc... </textarea>
The js will correctly parse out tags for the character count, but the field itself still considers the tags in applying max length, causing a mismatch between input and feedback.
Proposed solution
Potential fix attached in patch: move the maxlength attribute to a data-maxlength attribute; re-apply the maxlength attribute when necessary.
Comment | File | Size | Author |
---|---|---|---|
maxlengthjs.patch | 1.38 KB | angrytoast | |
Comments
Comment #1
angrytoast CreditAttribution: angrytoast commentedComment #2
cthos CreditAttribution: cthos commentedMight have a look over here as well, we did something similar to get word counts working: https://drupal.org/node/1496570
Comment #3
chasingmaxwell CreditAttribution: chasingmaxwell commentedThis may also be relevant to this issue: https://www.drupal.org/node/1841028#comment-9396967
Comment #4
cedeweyWe are only maintaining the Drupal 7 version of the module for critical security fixes, so I'm marking this Closed (won't fix). Thank you for working on this issue. If you do want to maintain the Drupal 7 version, do reach out. We'd be happy to bring you on board as a maintainer.
I also encourage you, if you haven't already, to upgrade your site to Drupal 8/9. We are actively maintaining that version and you would enjoy all of the other features of the latest version of Drupal.