Question

Here is a code

<?php 
if (isset($_POST['flag'])) {

    $length=strlen(trim($_POST['area']));
     echo "Length of abstract  :  ".$length;
     if (!strlen(trim($_POST['area']))){
        $abstractErrorMsg = "Please enter the abstract of your article";
        echo $abstractErrorMsg;
    }
}
?>
<form method="post" action="">
        <input type="hidden" name="flag" value="hidden">
        <script type="text/javascript" src="http://js.nicedit.com/nicEdit-latest.js"></script> 
        <script type="text/javascript">
                            //<![CDATA[
                            bkLib.onDomLoaded(function() {
                                nicEditors.editors.push(
                                        new nicEditor().panelInstance(
                                        document.getElementById('myNicEditor')
                                        )
                                        );
                            });
                            //]]>
                        </script>

                        * Abstract

                                <textarea name="area" id="myNicEditor" style="width: 300px;height: 100px;"></textarea>

        <input type="submit" name="btn">
    </form>

If i am submitting form without entering any text to nicedit textarea, it is showing length=4. Why it is so?Is there any default value of nicedit textarea ? If yes,how to change it?

Was it helpful?

Solution

By commenting the 3 lines solve the problem. Search for the below code in niceEdit.js. By default it contains a <br />.

init : function() {
            this.elm.setAttribute('contentEditable','true');    
            //if(this.getContent() == "") {
            //  this.setContent('<br />');
            //}
            this.instanceDoc = document.defaultView;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top