简体   繁体   English

与SCEditor集成的textarea的JS验证

[英]JS validation of textarea integrated with SCEditor

my JSFiddle. 我的JSFiddle。 http://jsfiddle.net/sky94132003/083u7y9g/ http://jsfiddle.net/sky94132003/083u7y9g/

I used SCEditor for a form textarea. 我将SCEditor用于表单文本区域。

I want to simple validation empty. 我想简单验证为空。

just a alert is ok. 只是警报就可以。

But Why I can't validation the SCEditor ??? 但是为什么我不能验证SCEditor呢?

if normal textarea will be ok? 正常的textarea可以吗?

this my js code. 这是我的js代码。 my js skill not good. 我的js技能不好。

//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? 如果不为null> true,如何正常检查文本区域?

I think maybe I can validation $('textarea').sceditor('instance') ???? 我想也许我可以验证$('textarea')。sceditor('instance')????

I fixed that problem. 我解决了这个问题。

The sceditor author answer me. 主持人作者回答了我。

using this API to get data 使用此API来获取数据

 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/ http://jsfiddle.net/sky94132003/083u7y9g/4/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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