I have a text-area
<td><textarea id="event-body" name="body">
<p class="error"></p>
That is integrated with CKEDITOR
CKEDITOR.replace("event-body")
And jquery validate plugin. And the code is like this
$('#event').validate({
rules:{
name:{
required: true
},
},
messages:{
body:{
required: "event body is required"
}
},
errorPlacement: function(error, element){
$(element).each(function (){
$(this).parent('td').find('p.error').html(error);
})
});
The code works just fine but when I type into my textarea
element, I still get the error message until I click it twice. i.e. I have to submit my page twice so that I don't error message even if textarea
is not empty.
Isn't there a way to validate it smoothly(without having to click it twice).
Take a look here
Basically you need to call
before running validation.
Just replace
editor1
with the name of your textarea.Then call
EDIT
Use this in your javascript where you are validating your form. It will update your ckeditor and will assign ckeditor's value to your textarea to which you integrate it.
It should run before form is submitted:
If you are attaching it like
than you will need to use something like this
I use this example function to submit my form in this case