Validate FCKEditor blank or not

给你一囗甜甜゛ 提交于 2019-12-12 03:14:59

问题


i am trying to validate using JavaScript if the fckeditor value is blank or not but with no luck.

i am creating the Editor using javascript :

var oFCKeditor = new FCKeditor('txtMessage');
                                                 oFCKeditor.BasePath = "../fckeditor/";
                                                 oFCKeditor.ToolbarSet = "Default";
                                                oFCKeditor.Height = "500";
                                                  oFCKeditor.Value = "test";
                                                oFCKeditor.Create();

but when i use:

 if (document.form.txtMessage.value == "") {
      alert('You Must Enter a Message');

when the editor is empty and alerts me and i write something in it, it keeps alerting it is empty.


回答1:


Check here

    <script type="text/javascript">
        function checksubmit() {        
            var FCKGetInstance = FCKeditorAPI.GetInstance('PageDescription');  
            var getText = FCKGetInstance.GetData(); 
            var StripTag = getText.replace(/(<([^>]+)>)/ig,"");
            if(StripTag=='') {
                alert("This is required field");
                return false;
            }
            else {
                alert(StripTag);
            }       
        }
     </script>

<input type="submit" name="submit" value="submit" onclick="javascript: return checksubmit();" />


来源:https://stackoverflow.com/questions/10596884/validate-fckeditor-blank-or-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!