Fields can have a maximum character limit, for example 100.
When using a WYSIWYG editor, it adds HTML tags to the field contents, increasing the field value size. That makes the real character count less than the field value size.
For example, if the field has a 100 character limit, we can type 100 characters. While we do that, the WYSIWYG editor added <p> and </p> tags to the start and end of those 100 characters, increasing the field value size to 107 -- therefore, the validation will fail saying that the field has 107 characters.

The feature request is to strip tags when verifying the field value size for fields that use a WYSIWYG editor.
I attached here a patch file that strips tags when checking field value size. I know that fields sometimes need to count all characters, but this patch is a start and is what we are using in our project.

CommentFileSizeAuthor
character_count.patch1.28 KBjpatiaga

Comments

makbul_khan8’s picture

Issue summary: View changes

This looks good to me!
Thanks for the patch

makbul_khan8’s picture

Status: Needs work » Reviewed & tested by the community

Patch Worked!!

stefan.r’s picture

Version: 7.0-beta3 » 8.3.x-dev
Status: Reviewed & tested by the community » Needs review

I don't think this is something we do in Drupal 8 -- any feature requests should go into Drupal 8 first before being backported into Drupal 7.

wturrell’s picture

Status: Needs review » Closed (works as designed)

I'm setting this to Closed (works as designed) - (if that's wrong, do feel free to reopen it - but please update the issue summary and clarify how to reproduce the problem, what the motivation is etc.)

a) as far as I can see in Drupal 8 the only way to use the WYSIWYG editor is to add a "Text formatted (long)" field, in which case a maximum length cannot be specified.

b) on fields where a maximum length is specified, I'd argue the expectation would be for it to be strictly enforced and any characters including HTML to count towards it? If you want to mix content and formatting, you should allow the field length to be unlimited.