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.

CommentFileSizeAuthor
maxlengthjs.patch1.38 KBangrytoast
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

angrytoast’s picture

Status: Active » Needs review
cthos’s picture

Might have a look over here as well, we did something similar to get word counts working: https://drupal.org/node/1496570

chasingmaxwell’s picture

Issue summary: View changes

This may also be relevant to this issue: https://www.drupal.org/node/1841028#comment-9396967

cedewey’s picture

Status: Needs review » Closed (won't fix)

We 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.