Validating Radeditor Content

4 posts, 0 answers
  1. Erin
    Erin avatar
    43 posts
    Member since:
    Mar 2008

    Posted 31 Aug 2008 Link to this post

    Hello, how can I tie the update button for the radeditor's content to a validation function?  I basically want to ensure that the user doesn't put javascript and/or links to external sites so I want to check the html of the content and throw an error message if any of these things are found.  I couldn't find a validation event and validation group for the radeditor....
  2. Rumen
    Rumen avatar
    13902 posts

    Posted 03 Sep 2008 Link to this post

    Hi Erin,

    The RadEditor's RemoveScripts filter automatically strips the SCRIPT tags in the content area.

    In addition, you can use the add_submit() method of RadEditor to validate the content. This method is executed when the page is submitted and you can obtain the editor's content with editor.get_html(true) and strip the desired tags and scripts with regular expressions or DOM methods.

    You can also use a CustomValidator to validate the content. Here is an example demonstrating how to count and restrict the symbols entered in the content area:

    <telerik:RadEditor ID="RadEditor1" runat="server"></telerik:RadEditor>
    <asp:CustomValidator runat="server" ID="CustomValidator1" ClientValidationFunction="checkLength">*</asp:CustomValidator> 
    <asp:Button ID="button1" Text="Submit" runat="server" /> 
    <script type="text/javascript"> 
        var limitNum = 50; 
        var message = 'You are not able to type more than ' + limitNum + ' symbols!'; 
        function checkLength(validator, args) 
            var editor = $find('<%=RadEditor1.ClientID%>');     // get a reference to RadEditor
            var editorText = editor.get_text();     //get the HTML content of the control
            args.IsValid = editorText.length < limitNum; 

    Kind regards,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Matt
    Matt avatar
    92 posts
    Member since:
    Jun 2012

    Posted 21 May 2013 Link to this post

    I know this post is old but I can't find ANYTHING recent...

    I'm just trying a simple test on an ASP.Net custom validator:


    And I get:

    Error: Unable to get value of the property 'get_text': object is null or undefined

    Has things changed that much? I'm using Q1 2013.
  4. Rumen
    Rumen avatar
    13902 posts

    Posted 24 May 2013 Link to this post


    You should get a valid reference to RadEditor's client side object to be able to use the get_text() method.
    Try remove the # symbol from the $find function and test again:


    I also tested the code provided in my earlier reply and it works fine with the latest version.

    Best regards,
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top