65.9K
CodeProject 正在变化。 阅读更多。
Home

FCKEditor 必填字段检查

starIconstarIconstarIconstarIconstarIcon

5.00/5 (1投票)

2013 年 10 月 11 日

CPOL
viewsIcon

6447

我们可能都会遇到为 FCKEditor 验证必填字段的问题。这里提供一个解决方案:您的 HTML 标记如下

我们可能都会遇到为 FCKEditor 验证必填字段的问题。这里提供一个解决方案

 

您的 FCKEditor HTML 标记

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

自定义验证器 Javascript 函数

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

 

只需使用以上代码即可为 FCKEditor 应用必填字段验证。

© . All rights reserved.