TinyMCE max length validation

Support General TinyMCE max length validation

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #35273

    Is there any way to add max length validation to a TinyMCE WYSIWYG field?
    Ideally this validation would be the same as a textarea field.

    #35296
    Long NguyenLong Nguyen
    Moderator

    Hi,

    The validation works with the field type wysiwyg, but works with the tab Text only. It does not work with the Visual tab.
    https://docs.metabox.io/validation/

    #35309

    In the case we have a custom field like this:

    function custom_wysiwyg(String $name, 
        bool $isRequired,
        bool $hasQuicktags,
        int $rows, 
        int $max_length,
        String $tags_allowed,
        String $formats_allowed
    ) {
        return [
            'name'     => $name,
            'id'       => strtolower($name),
            'type'     => 'wysiwyg',
            'required' => $isRequired,
            'options' => [
                'textarea_rows' => $rows,
                'tinymce' => [
                    'block_formats' => $formats_allowed,
                    'toolbar1' => $tags_allowed,
                ],
                'quicktags' => $hasQuicktags,
            ],
        ];
    }
    

    The validation would work? I did not understand the part of it not working with the Visual tab.

    #35337
    Long NguyenLong Nguyen
    Moderator

    Hi,

    Yes, the HTML validation 'required' => true is working on both the Visual and Text tabs. But the JS validation only works with the Text tab.
    https://docs.metabox.io/validation/

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.