FCKeditor自定义验证

来源:互联网 发布:java集合类迭代器 编辑:程序博客网 时间:2024/05/21 14:59

 <script type="text/javascript">
     var fckeditorContentLength = 0;
     //自定义难控件所邦定的客服端事件
     function checkFckeditorContent(source, arguments) {
         arguments.IsValid = (fckeditorContentLength > 0);
     }
     //FCK加载完毕后会自动调用名字为FCKeditor_OnComplete的函数;
     //将自身作为参数传递进来
     function FCKeditor_OnComplete(editorInstance) {
         //附加失去焦点的事件
         editorInstance.Events.AttachEvent('OnBlur', FCKeditor_OnBlur);
     }
     function FCKeditor_OnBlur(editorInstance) {
         fckeditorContentLength = editorInstance.GetXHTML(true).length;
         //在FCKeditor失去焦点时,如果内容不为空则隐藏验证提示
         if (fckeditorContentLength > 0) {
             document.getElementById("valxFCK").style.display = "none";
         }
     }
 </script>

//自定义验证控件,记住不要设置ControlToValidate属性

<asp:CustomValidator ID="valxFCK" runat="server" ErrorMessage="请输入内容" 
                     ValidationGroup="group1" Text="请输入内容"
                     Display="Dynamic" ClientValidationFunction="checkFckeditorContent"
                     onservervalidate="valxFCK_ServerValidate"></asp:CustomValidator>

原创粉丝点击