669
Views
6
Comments
Solved
[CKEditor] Max Length problem
Question
ckeditor
Web icon
Forge component by Matthias Preuter

Hi,

In the input box I have a Max. Length of 2000 characters,  but the CK Editor allowed me to write more than the max length and was also allowed to save it but saved just the value within the max character length.

Any way to use CK editor just like the normal input box behavior, not to allow typing or pasting characters more than the max length 


Thanks,

-Edwin


Solution

Hi Edwin,

On the demo module in CKEditor, check out the preparation of the CKEDemo screen.

The local variable cfg_wcount is set by default to -1. If you change it tot the max length you want, user will no longer be able to enter more that the specified maximum.

The property on the input area you set in outsystems for max length has no effect, because the CKEditor " under the hood"  does not use that.

Regards,

Daniel


extraPlugins: 'wordcount',
wordcount: {
    // Whether or not you want to show the Paragraphs Count
    showParagraphs: true,

    // Whether or not you want to show the Word Count
    showWordCount: true,

    // Whether or not you want to show the Char Count
    showCharCount: true,

    // Whether or not you want to count Spaces as Chars
    countSpacesAsChars: true,

    // Whether or not to include Html chars in the Char Count
    countHTML: false,
    
    // Maximum allowed Word Count, -1 is default for unlimited
    maxWordCount: -1,

    // Maximum allowed Char Count, -1 is default for unlimited
    maxCharCount: -1,
}
"


You probably should also set the countHTML property to true, to get the true length of the text to be stored in your entity.

Hi Daniel,

I managed to do this before I saw your solution, but you are correct.


Another question though, how can I remove/change the label "Characters (with HTML):"


I am marking your suggestion as solution.


Thanks,

-Edwin

Hi,

You can change that text in the approriate language file on the resource tab in Data tab (of the CKeditor module.

Scroll down to the .\ckeditor\plugins\wourdcount\lang files and save the en.js file to disk, edit it and load it back.

Daniël Kuhlmann wrote:

Hi,

You can change that text in the approriate language file on the resource tab in Data tab (of the CKeditor module.

Scroll down to the .\ckeditor\plugins\wourdcount\lang files and save the en.js file to disk, edit it and load it back.

Hi Daniel,

Great!

I wish I could mark this as solution twice :D

Thanks!

Regards,

-Edwin


How to stop typing when maximum limit exceed in text area field in CKeditor5

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.