Home / ASP.NET Wiki / Javascript / RequireField Check for FCKEditor

RequireField Check for FCKEditor

 Rate It (0)

We all may encounter a problem of validating RequiredField for FCKEditor. Here is the Solution:

 

Your HTML Markup for FCKEditor:

<FCKeditorV2:FCKeditor ID="HTMLFCKeditor" runat="server" Height="400px" Width="100%">
</FCKeditorV2:FCKeditor>
<asp:CustomValidator ID="CustomValidator2" runat="server" ValidationGroup="Invitation"
ErrorMessage="Enter Message !" Display="Dynamic" ClientValidationFunction="ValidateFCKEditor"></asp:CustomValidator>

CustomValidator Javascript Function:

function ValidateFCKEditor(source, args)
{
    var fckEditorClientID = document.getElementById('<%=HTMLFCKeditor.ClientID%>');              
    args.IsValid = FCKeditorAPI.GetInstance(fckEditorClientID.id).GetXHTML(true) != "";      
}

 

Just use above code to apply RequiredField Validation for FCKEditor.

Revision number 2, Thursday, May 21, 2009 10:12:44 PM by mbanavige

Comments

Shortcuts

Table of Contents

Top Wiki Contributors

(last 30 days)

  1. abiruban (1)