0

CKEditor でサポートされているテキストエリアを含むフォームを検証しようとしています。しかし今では、エラーはまったく表示されず、コードも送信されません。

このトピックに関連するすべての回答を読みましたが、コードを機能させることができませんでした。

これは私がこれまでに得たものです:

if(jQuery().validate) {
    $("#submit_button").click(function(e){
        e.preventDefault();
        CKEDITOR.instances.editor1.updateElement();

        $(" #content_form ").validate({
            ignore: "input:hidden:not(input:hidden.required),input:hidden:not(input:hidden.editor1)",
            errorPlacement: function(error, element) {
                if (element.attr("name") == "editor1")
                {
                    error.insertBefore("#editor1");
                }
                else
                {
                    error.insertAfter(element);
                }
            },
            rules: {
                title: {
                    required: true,
                    minlength: 5
                },
                editor1: {
                    required: true,
                    minlength: 10
                },
                imglink: {
                    url:true
                },
            },
            messages: {
                title: "The title field is required.",
                editor1: "The content field is required.",
                imglink: "You must provide a valid URL."
            }
        });
    });
}

あなたの誰かがこれを理解するのを助けることができれば、私は非常に感謝しています.

前もって感謝します。

4

2 に答える 2

0

私がやっている方法は次のようなものです:

CKEDITOR.instances['txtSomeTextbox'].updateElement(); // this will update text in the hidden textbox that CKE is using.

// or if you have multiple instances 
// for (var i in CKEDITOR.instances) {
//CKEDITOR.instances[i].updateElement(); // to update the textarea
//}

次に、次のようにテキストボックスの値を取得します。

var mytext = CKEDITOR.instances.txtSomeTextbox.getData();

これで mytext を使用して検証を行うことができます..

于 2013-11-05T13:17:43.877 に答える