i have searched and tried many different things, yet i haven't found any answer yet.

i am validating a simple form with just a textarea using jquery validation.. it works well with a textarea. but whenever i try using ckeditor, the form submits without any validation.

here is my form.

<form action="/answer/store/{{$questionData->id}}/{{ rand(1,3)}}" method="POST" id="commentform" class="comment-form">
    @csrf
        <div id="respond-textarea">
            <p>
                <label class="required" for="comment">Details<span>*</span></label>
                <textarea id="comment" name="answer" class="ckeditor" aria-required="true" cols="58" rows="8"></textarea>
            </p>
        </div>

        <p class="form-submit">
            <input name="submit" type="submit" id="submit" value="Post your answer" class="button small color">
        </p>
    </form>

here is my jquery validation script

$("#commentform").validate({
ignore: [],
debug: false,
rules: {
  answer: {
    required: function() {
                CKEDITOR.instances.answer.updateElement();
    }
  }
},
messages: {
  answer: {
    required: 'the answer field cannot be empty.'
  }
}
});

0 Answers