Character Limit In RadEditor

4 posts, 0 answers
  1. Rodney
    Rodney avatar
    54 posts
    Member since:
    Mar 2015

    Posted 18 May 2017 Link to this post

    I need to provide character limit functionality in RadEditor and have been having a significant number of issues getting a comprehensive solution. I've read a number of items on the Forum that sometimes give conflicting and incomplete solutions.

    Requirement:

    • Prevent typing of more than n Number of characters
    • Prevent pasting of more than n Number of characters
    • Ability to strip formatting from pasted content
    • Multiple Editors on the same page or AJAX Modal Popup

    The last article I was looking at was: http://www.telerik.com/forums/charector-limit-in-rad-editor#662718 which is pretty close in functionality to what I need, but when determining the length of the content on the clipboard the formatting from Word, or wherever you picked the text up from is included in that length.

    If you could provide some code snippets or point me to an article that will correctly work I would appreciate it.

    Rodney

  2. Rumen
    Admin
    Rumen avatar
    14280 posts

    Posted 23 May 2017 Link to this post

    Hi Rodney,

    RadEditor officially supports only the MaxTextLength and MaxHtmlLength properties/features.

    The custom solutions shared and discussed in the Character limit in Rad:Editor forum cover almost everything asked over the years for this scenario, but they are not part of the supported features of RadEditor. You can use them as a base to proceed with your custom scenario and modifying them depending on your needs and used browser.

    Best regards,
    Rumen
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Rodney
    Rodney avatar
    54 posts
    Member since:
    Mar 2015

    Posted 02 Jun 2017 in reply to Rumen Link to this post

    Here's my problem. We use the RadEditorStatistics for all of our RedEditors. This only counts visible characters, not actual characters which the MaxHtmlLength does. So if I have a text box that allows 4000 characters and my DB field is 4000 characters and there is any formatting at all in the text the MaxTexLegth won't give a message, but the MaxHtmlWill, but the statistics say there are 4000 characters and my users don't understand why they are getting an error.

    Isn't there some way to come up with a unified approach to this? Something that would get all of the options of the control to work together instead of against each other?

    Thanks

    Rodney

  4. Rumen
    Admin
    Rumen avatar
    14280 posts

    Posted 05 Jun 2017 Link to this post

    Hello Rodney,

    You can modify the default behavior of the statistics module of RadEditor as shown in this thread: http://www.telerik.com/forums/how-to-make-statistics-module-fire-for-every-keystroke#PfHC1gThR0OejXkCDFCUtg and remove the reg expressions which strip the special symbols and the markup:

     

    punctRegX = /[!\.?;,:&_\-\-\{\}\[\]\(\)~#'"]/g;
    //content = content.replace(punctRegX, "");
    trimRegX = /(^\s+)|(\s+$)/g;
    //content = content.replace(trimRegX, "");

     

    Best regards,
    Rumen
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top