简体   繁体   中英

JS validation of textarea integrated with SCEditor

my JSFiddle. http://jsfiddle.net/sky94132003/083u7y9g/

I used SCEditor for a form textarea.

I want to simple validation empty.

just a alert is ok.

But Why I can't validation the SCEditor ???

if normal textarea will be ok?

this my js code. my js skill not good.

//validation
    function check(form) {
        var Message = form["message_content"];
        if (test(Message) === false) {
            alert("content??");
            return false;
        }
    }

    function test(textarea) {
        var val = textarea.value;
        if (val == "" || !val) {
            return false;
        }
        return true;
    }

how can I normal check the textarea if not null > true?

I think maybe I can validation $('textarea').sceditor('instance') ????

I fixed that problem.

The sceditor author answer me.

using this API to get data

 var val = $('#message_content').sceditor('instance').val();

So, I fixed that problem in this demo

If you need that , you may go to the test on here

http://jsfiddle.net/sky94132003/083u7y9g/4/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM