How to clear all Non-Visible characters when there is no visible content

3 posts, 0 answers
  1. j
    j avatar
    1 posts
    Member since:
    Apr 2018

    Posted 16 Apr 2018 Link to this post

    Hey folks,

    This should be an easy one, but unfortunately not finding an easy way around it.


    Problem Statement: When there are no visible characters in the input area, strip out all non-visible characters.


                Our users can copy past from word files and or other sources, then they can decide to remove it.But this creates HTML equivalents of non-visible characters like 1) Tab, 2) whitespaces, 3)Carriage Returns or any other possible non-visible characters. My requirement is simple, if there are no visible characters, the input area should be reset to nothing or null.But in my case HTML equivalents of the above mentioned visible chars are saved which is not ideal.

    I tied some JS to strip those using regular expressions, but not quite working, tried server side one too(c#) but it is messing up the visible content too. Is there a property I can set to make this working ?


    Thanks for  your help!

  2. Marcel
    Marcel avatar
    1 posts
    Member since:
    Nov 2016

    Posted 14 May 2018 in reply to j Link to this post

    I have the same problem since updating to the new version

    &  is always present in the text returned to the server

    any solutions ???

  3. Marin Bratanov
    Marin Bratanov avatar
    5325 posts

    Posted 17 May 2018 Link to this post


    The most likely reason for such behavior is that the user does not select all the content (e..g, when using the mouse) and thus some content is left over.

    I am attaching a short video with the expected behavior of using ctrl+a and then del or backspace.

    @Marcel - it is possible that a proxy or some browser extension is adding that the POST. In any case, if you get this consistently instead of an empty string, you can add a check to see if this is all you get and if so - consider it empty.

    @j - this is actually not easy at all, because non-breaking spaces can get created by the user (e..g, when holding the space button). They will not be seen by the user, but they are still part of the content and so the editor must not remove them on its own, because they will often be required as part of the content. Nevertheless, you  can use the .Text server property or get_text() methods to get the text equivalent of the content. So, if trimming it (e..g, the JS .trim() or C#'s Trim() methods on that string return an empty string - you'll know it's all whitespace.

    Marin Bratanov
    Progress Telerik
    Try our brand new, jQuery-free Angular 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