Home > AJAX, ASP.Net, Javascript > AJAX HTML Editor and validation

AJAX HTML Editor and validation


Hi

try this example to validate AJAX  HTML editor :

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="TestWithValidation.aspx.vb"
    Inherits="SoluTest_HTMLEditor.TestWithValidation" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit.HTMLEditor"
    TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>">
<html xmlns="<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        function test() {
            var a = $find("<%=Editor1.ClientID%>");
            var value = a.get_content();
            if (value == "") {
                $get("result").innerHTML = "Editor's content is empty";
                return false;
            }           
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <cc1:Editor ID="Editor1" runat="server" Width="300" Height="300" ValidationGroup="Editor" />
        <br />
        <span id="result"></span>
        <br />
        <asp:Button ID="Button1" runat="server" Text="Submit" OnClientClick="return test();"
            CausesValidation="true" ValidationGroup="Editor" />
    </div>
    </form>
</body>
</html>

Hope this helps

Good Luck

Advertisements
Categories: AJAX, ASP.Net, Javascript
  1. Rahul
    February 21, 2010 at 5:48 am

    this code is not working

  2. Sreerejith SS
    May 30, 2012 at 10:02 am

    Thank you very much

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: