user1395625 user1395625 - 1 year ago 81
Javascript Question

Validate FCKEditor blank or not

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";

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.

Answer Source

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 {

<input type="submit" name="submit" value="submit" onclick="javascript: return checksubmit();" />
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download